ocaml-containers/3.0/containers-thread/CCSemaphore/index.html
Simon Cruanes 2fa8e5f507 fix doc
2020-08-04 09:49:29 -04:00

2 lines
No EOL
3.4 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>CCSemaphore (containers-thread.CCSemaphore)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> <a href="../index.html">containers-thread</a> &#x00BB; CCSemaphore</nav><h1>Module <code>CCSemaphore</code></h1><h2 id="semaphores"><a href="#semaphores" class="anchor"></a>Semaphores</h2><dl><dt>since</dt><dd>0.13</dd></dl></header><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> t</code></dt><dd><p>A semaphore</p></dd></dl><dl><dt class="spec value" id="val-create"><a href="#val-create" class="anchor"></a><code><span class="keyword">val</span> create : int <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>create n</code> creates a semaphore with initial value <code>n</code>.</p><dl><dt>raises Invalid_argument</dt><dd><p>if <code>n &lt;= 0</code>.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-get"><a href="#val-get" class="anchor"></a><code><span class="keyword">val</span> get : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> int</code></dt><dd><p>Current value.</p></dd></dl><dl><dt class="spec value" id="val-acquire"><a href="#val-acquire" class="anchor"></a><code><span class="keyword">val</span> acquire : int <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt><dd><p><code>acquire n s</code> blocks until <code>get s &gt;= n</code>, then atomically sets <code>s := !s - n</code>.</p></dd></dl><dl><dt class="spec value" id="val-release"><a href="#val-release" class="anchor"></a><code><span class="keyword">val</span> release : int <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt><dd><p><code>release n s</code> atomically sets <code>s := !s + n</code>.</p></dd></dl><dl><dt class="spec value" id="val-with_acquire"><a href="#val-with_acquire" class="anchor"></a><code><span class="keyword">val</span> with_acquire : <span>n:int</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <span>f:<span>(unit <span>&#45;&gt;</span> <span class="type-var">'a</span>)</span></span> <span>&#45;&gt;</span> <span class="type-var">'a</span></code></dt><dd><p><code>with_acquire ~n s ~f</code> first acquires <code>s</code> with <code>n</code> units, calls <code>f ()</code>, and then releases <code>s</code> with <code>n</code> units. Safely release the semaphore even if <code>f ()</code> fails.</p></dd></dl><dl><dt class="spec value" id="val-wait_until_at_least"><a href="#val-wait_until_at_least" class="anchor"></a><code><span class="keyword">val</span> wait_until_at_least : <span>n:int</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <span>f:<span>(unit <span>&#45;&gt;</span> <span class="type-var">'a</span>)</span></span> <span>&#45;&gt;</span> <span class="type-var">'a</span></code></dt><dd><p><code>wait_until_at_least ~n s ~f</code> waits until <code>get s &gt;= n</code>, then calls <code>f ()</code> and returns its result. Doesn't modify the semaphore.</p></dd></dl></div></body></html>