You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: js/search.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
//DO NOT EDIT generated by /home/jmerelo/Code/raku/raku-doc-generated/site#sources/677E0B857640AD7C699D43EAFA5F9550AE91E0B5 (Documentable::DocPage::Factory):138
1
+
//DO NOT EDIT generated by /home/jmerelo/Code/raku/my-raku-examples/site#sources/677E0B857640AD7C699D43EAFA5F9550AE91E0B5 (Documentable::DocPage::Factory):138
<trclass="toc-level-2"><tdclass="toc-number">0.1</td><tdclass="toc-text"><ahref="#CompUnit::*_modules_and_roles"><codeclass="pod-code-inline">CompUnit::*</code> modules and roles </a></td></tr>
<p>The Rakudo implementation has a few modules included you may want to use. The following is a list of them, along with links to their source code.</p>
77
+
<p>The Rakudo implementation has a few modules included you may want to use; please note that the implementation is not part of the Raku specification and thus might be subject to change without prior notice. The following is a list of them, along with links to their source code.</p>
78
78
<h2id="CompUnit::*_modules_and_roles"><aclass="u" href="#___top" title="go to top of document"><code>CompUnit::*</code> modules and roles <aname="index-entry-CompUnit_(Rakudo_classes)"></a></a></h2>
79
79
<p>These modules are mostly used by distribution build tools, and are not intended to be used (at least until version 6.c) by the final user.</p>
@@ -95,9 +95,10 @@ <h2 id="NativeCall_modules"><a class="u" href="#___top" title="go to top of docu
95
95
<h2id="Other_modules"><aclass="u" href="#___top" title="go to top of document">Other modules</a></h2>
96
96
<ul><li><p><ahref="https://github.com/rakudo/rakudo/blob/master/lib/Pod/To/Text.rakumod"><code>Pod::To::Text</code></a> Used by several external modules</p>
97
97
</li>
98
-
<li><p><ahref="https://github.com/rakudo/rakudo/blob/master/lib/Test.rakumod"><code>Test</code></a> Test routines (<ahref="/language/testing">docs</a>)</p>
98
+
<li><p><ahref="/type/Test"><code>Test</code></a> Test routines (see <ahref="/language/testing">tutorial</a>)</p>
<preclass="editor editor-colors"><divclass="line"><spanclass="source raku"><spanclass="storage type declarator type raku"><span>method</span></span><span> </span><spanclass="entity name function raku"><span>with-lock-hidden-from-recursion-check</span></span><span>(</span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>&</span></span><spanclass="variable other identifier raku"><span>code</span></span></span><span>)</span></span></div></pre><p>Temporarily resets the Lock::Async recursion list so that it no longer includes the lock this method is called on and runs the given <code>&code</code> immediately if the call to the method occurred in a caller chain where <ahref="/type/Lock::Async/#method_protect-or-queue-on-recursion">protect-or-queue-on-recursion</a> has already been called and the lock has been placed on the recursion list.</p>
88
+
<preclass="editor editor-colors"><divclass="line"><spanclass="source raku"><spanclass="storage type declarator type raku"><span>method</span></span><span> </span><spanclass="entity name function raku"><span>with-lock-hidden-from-recursion-check</span></span><span>(</span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>&</span></span><spanclass="variable other identifier raku"><span>code</span></span></span><span>)</span></span></div></pre><p>Temporarily resets the Lock::Async recursion list so that it no longer includes the lock this method is called on and runs the given <code>&code</code> immediately if the call to the method occurred in a caller chain where <ahref="/type/Lock::Async#method_protect-or-queue-on-recursion">protect-or-queue-on-recursion</a> has already been called and the lock has been placed on the recursion list.</p>
89
89
<preclass="editor editor-colors"><divclass="line"><spanclass="source raku"><spanclass="storage modifier declarator raku"><span>my</span></span><span> </span><spanclass="support type raku"><span>Lock</span></span><span>::</span><spanclass="routine name raku"><span>Async</span></span><span> </span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>$</span></span><spanclass="variable other identifier raku"><span>lock</span></span></span><span> </span><spanclass="storage modifier assignment raku"><span>.=</span></span><span> </span><spanclass="support function raku"><span>new</span></span><span>;</span></span></div><divclass="line"><spanclass="source raku"><spanclass="storage modifier declarator raku"><span>my</span></span><span> </span><spanclass="support type raku"><span>Int</span></span><span> </span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>$</span></span><spanclass="variable other identifier raku"><span>count</span></span></span><span> </span><spanclass="storage modifier assignment raku"><span>=</span></span><span> </span><spanclass="constant numeric raku"><span>0</span></span><span>;</span></span></div><divclass="line"><spanclass="source raku"><span> </span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>$</span></span><spanclass="variable other identifier raku"><span>lock</span></span></span><spanclass="keyword operator generic raku"><span>.</span></span><spanclass="routine name raku"><span>protect-or-queue-on-recursion</span></span><span>(</span><spanclass="meta block raku"><spanclass="punctuation definition block raku"><span>{</span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><span> </span><spanclass="storage modifier declarator raku"><span>my</span></span><span> </span><spanclass="support type raku"><span>Int</span></span><span> </span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>$</span></span><spanclass="variable other identifier raku"><span>count</span></span></span><span> </span><spanclass="storage modifier assignment raku"><span>=</span></span><span> </span><spanclass="constant numeric raku"><span>0</span></span><span>;</span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><span> </span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><spanclass="punctuation whitespace comment leading raku"><span> </span></span><spanclass="comment line number-sign raku"><spanclass="punctuation definition comment raku"><span>#</span></span><span> Runs instantly.</span><span> </span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><span> </span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>$</span></span><spanclass="variable other identifier raku"><span>lock</span></span></span><spanclass="keyword operator generic raku"><span>.</span></span><spanclass="routine name raku"><span>with-lock-hidden-from-recursion-check</span></span><span>(</span><spanclass="meta block raku"><spanclass="punctuation definition block raku"><span>{</span></span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><spanclass="meta block raku"><span> </span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>$</span></span><spanclass="variable other identifier raku"><span>count</span></span></span><spanclass="keyword operator multi-symbol raku"><span>++</span></span><span>;</span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><spanclass="meta block raku"><span> </span><spanclass="punctuation definition block raku"><span>}</span></span></span><span>);</span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><span> </span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><spanclass="punctuation whitespace comment leading raku"><span> </span></span><spanclass="comment line number-sign raku"><spanclass="punctuation definition comment raku"><span>#</span></span><span> Runs after the outer caller's protect-or-queue-on-recursion call has</span><span> </span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><spanclass="punctuation whitespace comment leading raku"><span> </span></span><spanclass="comment line number-sign raku"><spanclass="punctuation definition comment raku"><span>#</span></span><span> finished running.</span><span> </span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><span> </span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>$</span></span><spanclass="variable other identifier raku"><span>lock</span></span></span><spanclass="keyword operator generic raku"><span>.</span></span><spanclass="routine name raku"><span>protect-or-queue-on-recursion</span></span><span>(</span><spanclass="meta block raku"><spanclass="punctuation definition block raku"><span>{</span></span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><spanclass="meta block raku"><span> </span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>$</span></span><spanclass="variable other identifier raku"><span>count</span></span></span><spanclass="keyword operator multi-symbol raku"><span>++</span></span><span>;</span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><spanclass="meta block raku"><span> </span><spanclass="punctuation definition block raku"><span>}</span></span></span><span>)</span><spanclass="keyword operator generic raku"><span>.</span></span><spanclass="routine name raku"><span>then</span></span><span>(</span><spanclass="meta block raku"><spanclass="punctuation definition block raku"><span>{</span></span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><spanclass="meta block raku"><span> </span><spanclass="support function raku"><span>say</span></span><span> </span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>$</span></span><spanclass="variable other identifier raku"><span>count</span></span></span><span>; </span><spanclass="comment line number-sign raku"><spanclass="punctuation definition comment raku"><span>#</span></span><span> OUTPUT: 2</span><span> </span></span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><spanclass="meta block raku"><span> </span><spanclass="punctuation definition block raku"><span>}</span></span></span><span>);</span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><span> </span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><span> </span><spanclass="support function raku"><span>say</span></span><span> </span><spanclass="meta variable container raku"><spanclass="variable other identifier sigil raku"><span>$</span></span><spanclass="variable other identifier raku"><span>count</span></span></span><span>; </span><spanclass="comment line number-sign raku"><spanclass="punctuation definition comment raku"><span>#</span></span><span> OUTPUT: 1</span><span> </span></span></span></span></div><divclass="line"><spanclass="source raku"><spanclass="meta block raku"><spanclass="punctuation definition block raku"><span>}</span></span></span><span>);</span></span></div></pre>
<p>It's important to understand that there is no direct connection between a <code>Lock</code> and any particular piece of data; it is up to the programmer to ensure that the <code>Lock</code> is held during all operations that involve the data in question. The <code>OO::Monitors</code> module, while not a complete solution to this problem, does provide a way to avoid dealing with the lock explicitly and encourage a more structured approach.</p>
90
90
<p>The <code>Lock</code> class is backed by operating-system provided constructs, and so a thread that is waiting to acquire a lock is, from the point of view of the operating system, blocked.</p>
91
91
<p>Code using high-level Raku concurrency constructs should avoid using <code>Lock</code>. Waiting to acquire a <code>Lock</code> blocks a real <code>Thread</code>, meaning that the thread pool (used by numerous higher-level Raku concurrency mechanisms) cannot use that thread in the meantime for anything else.</p>
92
-
<p>Any <code>await</code> performed while a <code>Lock</code> is held will behave in a blocking manner; the standard non-blocking behavior of <code>await</code> relies on the code following the `await` resuming on a different <code>Thread</code> from the pool, which is incompatible with the requirement that a <code>Lock</code> be unlocked by the same thread that locked it. See <ahref="/type/Lock::Async">Lock::Async</a> for an alternative mechanism that does not have this shortcoming.</p>
92
+
<p>Any <code>await</code> performed while a <code>Lock</code> is held will behave in a blocking manner; the standard non-blocking behavior of <code>await</code> relies on the code following the `await` resuming on a different <code>Thread</code> from the pool, which is incompatible with the requirement that a <code>Lock</code> be unlocked by the same thread that locked it. See <ahref="/type/Lock::Async">Lock::Async</a> for an alternative mechanism that does not have this shortcoming. Other than that, the main difference is that <code>Lock</code> mainly maps to operating system mechanisms, while <code>Lock::Async</code> uses Raku primitives to achieve similar effects. If you're doing low-level stuff (native bindings) and/or actually want to block real OS threads, use <code>Lock</code>. However, if you want a non-blocking mutual exclusion and don't need recursion and are running code on the Raku thread pool, use Lock::Async.</p>
93
93
<p>By their nature, <code>Lock</code>s are not composable, and it is possible to end up with hangs should circular dependencies on locks occur. Prefer to structure concurrent programs such that they communicate results rather than modify shared data structures, using mechanisms like <ahref="/type/Promise">Promise</a>, <ahref="/type/Channel">Channel</a> and <ahref="/type/Supply">Supply</a>.</p>
94
94
<h1id="Methods"><aclass="u" href="#___top" title="go to top of document">Methods</a></h1>
95
95
<h2id="method_protect"><aclass="u" href="#___top" title="go to top of document">method protect</a></h2>
0 commit comments