moonpool/dev/ocaml/Stdlib/Semaphore/Binary/index.html
2023-08-29 18:39:53 +00:00

2 lines
No EOL
3.1 KiB
HTML
Raw 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>Binary (ocaml.Stdlib.Semaphore.Binary)</title><link rel="stylesheet" href="../../../../_odoc-theme/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../../index.html">ocaml</a> &#x00BB; <a href="../../index.html">Stdlib</a> &#x00BB; <a href="../index.html">Semaphore</a> &#x00BB; Binary</nav><header class="odoc-preamble"><h1>Module <code><span>Semaphore.Binary</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span></code></div><div class="spec-doc"><p>The type of binary semaphores.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-make"><a href="#val-make" class="anchor"></a><code><span><span class="keyword">val</span> make : <span>bool <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>make b</code> returns a new binary semaphore. If <code>b</code> is <code>true</code>, the initial value of the semaphore is 1, meaning &quot;available&quot;. If <code>b</code> is <code>false</code>, the initial value of the semaphore is 0, meaning &quot;unavailable&quot;.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-release"><a href="#val-release" class="anchor"></a><code><span><span class="keyword">val</span> release : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>release s</code> sets the value of semaphore <code>s</code> to 1, putting it in the &quot;available&quot; state. If other threads are waiting on <code>s</code>, one of them is restarted.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-acquire"><a href="#val-acquire" class="anchor"></a><code><span><span class="keyword">val</span> acquire : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>acquire s</code> blocks the calling thread until the semaphore <code>s</code> has value 1 (is available), then atomically sets it to 0 and returns.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-try_acquire"><a href="#val-try_acquire" class="anchor"></a><code><span><span class="keyword">val</span> try_acquire : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>try_acquire s</code> immediately returns <code>false</code> if the semaphore <code>s</code> has value 0. If <code>s</code> has value 1, its value is atomically set to 0 and <code>try_acquire s</code> returns <code>true</code>.</p></div></div></div></body></html>