mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-09 12:45:46 -05:00
2 lines
6.7 KiB
HTML
2 lines
6.7 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Promise (picos_std.Picos_std_structured.Promise)</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">picos_std</a> » <a href="../index.html">Picos_std_structured</a> » Promise</nav><header class="odoc-preamble"><h1>Module <code><span>Picos_std_structured.Promise</span></code></h1><p>A cancelable promise.</p><p>ℹ️ In addition to using a promise to concurrently compute and return a value, a cancelable promise can also represent a concurrent fiber that will continue until it is explicitly <a href="#val-try_terminate" title="try_terminate">canceled</a>.</p></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> <span>!'a t</span></span></code></div><div class="spec-doc"><p>Represents a promise to return value of type <code>'a</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-of_value"><a href="#val-of_value" class="anchor"></a><code><span><span class="keyword">val</span> of_value : <span><span class="type-var">'a</span> <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>of_value value</code> returns a constant completed promise that returns the given <code>value</code>.</p><p>ℹ️ Promises can also be created in the scope of a <a href="../Bundle/index.html#val-fork_as_promise" title="Bundle.fork_as_promise"><code>Bundle</code></a> or a <a href="../Flock/index.html#val-fork_as_promise" title="Flock.fork_as_promise"><code>Flock</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-await"><a href="#val-await" class="anchor"></a><code><span><span class="keyword">val</span> await : <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">-></span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p><code>await promise</code> awaits until the promise has completed and either returns the <code>value</code> that the evaluation of the promise returned, raises the exception that the evaluation of the promise raised, or raises the <a href="../Control/index.html#exception-Terminate" title="Control.Terminate"><code>Terminate</code></a> exception in case the promise has been canceled.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-completed"><a href="#val-completed" class="anchor"></a><code><span><span class="keyword">val</span> completed : <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="../../Picos_std_event/Event/index.html#type-t">Picos_std_event.Event.t</a></span></span></code></div><div class="spec-doc"><p><code>completed promise</code> returns an <a href="../../Picos_std_event/Event/index.html" title="Picos_std_event.Event">event</a> that can be committed to once the promise has completed.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_running"><a href="#val-is_running" class="anchor"></a><code><span><span class="keyword">val</span> is_running : <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p><code>is_running promise</code> determines whether the completion of the promise is still pending.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-try_terminate"><a href="#val-try_terminate" class="anchor"></a><code><span><span class="keyword">val</span> try_terminate : <span><span class="optlabel">?callstack</span>:int <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> bool</span></code></div><div class="spec-doc"><p><code>try_terminate promise</code> tries to terminate the promise by canceling it with the <a href="../Control/index.html#exception-Terminate" title="Control.Terminate"><code>Terminate</code></a> exception and returns <code>true</code> in case of success and <code>false</code> in case the promise had already completed, i.e. either returned, raised, or canceled.</p><p>The optional <code>callstack</code> argument specifies the number of callstack entries to capture with the <a href="../Control/index.html#exception-Terminate" title="Control.Terminate"><code>Terminate</code></a> exception. The default is <code>0</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-terminate"><a href="#val-terminate" class="anchor"></a><code><span><span class="keyword">val</span> terminate : <span><span class="optlabel">?callstack</span>:int <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> unit</span></code></div><div class="spec-doc"><p><code>terminate promise</code> is equivalent to <a href="#val-try_terminate" title="try_terminate"><code>try_terminate promise |> ignore</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-terminate_after"><a href="#val-terminate_after" class="anchor"></a><code><span><span class="keyword">val</span> terminate_after : <span><span class="optlabel">?callstack</span>:int <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="label">seconds</span>:float <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>terminate_after ~seconds promise</code> arranges to terminate the <code>promise</code> by canceling it with the <a href="../Control/index.html#exception-Terminate" title="Control.Terminate"><code>Terminate</code></a> exception after the specified timeout in <code>seconds</code>.</p><p>The optional <code>callstack</code> argument specifies the number of callstack entries to capture with the <a href="../Control/index.html#exception-Terminate" title="Control.Terminate"><code>Terminate</code></a> exception. The default is <code>0</code>.</p></div></div></div></body></html>
|