mirror of
https://github.com/c-cube/linol.git
synced 2025-12-06 03:05:31 -05:00
2 lines
4.5 KiB
HTML
2 lines
4.5 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_condition (lwt.Lwt_condition)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.3"/><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">lwt</a> » Lwt_condition</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_condition</span></code></h1><p>Conditions</p></header><div class="odoc-content"><p>Condition variables to synchronize between threads.</p><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> <span>'a t</span></span></code></div><div class="spec-doc"><p>Condition variable type. The type parameter denotes the type of value propagated from notifier to waiter.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-create"><a href="#val-create" class="anchor"></a><code><span><span class="keyword">val</span> create : <span>unit <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>create ()</code> creates a new condition variable.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-wait"><a href="#val-wait" class="anchor"></a><code><span><span class="keyword">val</span> wait : <span><span class="optlabel">?mutex</span>:<a href="../Lwt_mutex/index.html#type-t">Lwt_mutex.t</a> <span class="arrow">-></span></span> <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>wait mutex condvar</code> will cause the current thread to block, awaiting notification for a condition variable, <code>condvar</code>. If provided, the <code>mutex</code> must have been previously locked (within the scope of <code>Lwt_mutex.with_lock</code>, for example) and is temporarily unlocked until the condition is notified. Upon notification, <code>mutex</code> is re-locked before <code>wait</code> returns and the thread's activity is resumed. When the awaited condition is notified, the value parameter passed to <code>signal</code> is returned.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-signal"><a href="#val-signal" class="anchor"></a><code><span><span class="keyword">val</span> signal : <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>signal condvar value</code> notifies that a condition is ready. A single waiting thread will be awoken and will receive the notification value which will be returned from <code>wait</code>. Note that condition notification is not "sticky", i.e. if there is no waiter when <code>signal</code> is called, the notification will be missed and the value discarded.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-broadcast"><a href="#val-broadcast" class="anchor"></a><code><span><span class="keyword">val</span> broadcast : <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>broadcast condvar value</code> notifies all waiting threads. Each will be awoken in turn and will receive the same notification value.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-broadcast_exn"><a href="#val-broadcast_exn" class="anchor"></a><code><span><span class="keyword">val</span> broadcast_exn : <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">-></span></span> <span>exn <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>broadcast_exn condvar exn</code> fails all waiting threads with exception <code>exn</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.6.0</li></ul></div></div></div></body></html>
|