mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-09 20:55:35 -05:00
2 lines
7.7 KiB
HTML
2 lines
7.7 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Stream (picos_std.Picos_std_sync.Stream)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.1.0"/><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">Index</a> » <a href="../../index.html">picos_std</a> » <a href="../index.html">Picos_std_sync</a> » Stream</nav><header class="odoc-preamble"><h1>Module <code><span>Picos_std_sync.Stream</span></code></h1><p>A lock-free, poisonable, many-to-many, stream.</p><p>Readers can <a href="#val-tap"><code>tap</code></a> into a stream to get a <a href="#type-cursor"><code>cursor</code></a> for reading all the values <a href="#val-push" title="push">pushed</a> to the stream starting from the <a href="#type-cursor"><code>cursor</code></a> position. Conversely, values <a href="#val-push" title="push">pushed</a> to a stream are lost unless a reader has a <a href="#type-cursor"><code>cursor</code></a> to the position in the stream.</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 stream of values of type <code>'a</code>.</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><span class="optlabel">?padded</span>:bool <span class="arrow">-></span></span> <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> returns a new stream.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-push"><a href="#val-push" class="anchor"></a><code><span><span class="keyword">val</span> push : <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>push stream value</code> adds the <code>value</code> to the current position of the <code>stream</code> and advances the stream to the next position unless the <code>stream</code> has been <a href="#val-poison" title="poison">poisoned</a> in which case only the exception given to <a href="#val-poison"><code>poison</code></a> will be raised.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-poison_at"><a href="#val-poison_at" class="anchor"></a><code><span><span class="keyword">val</span> poison_at : <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> <span><a href="../../../ocaml/Stdlib/Printexc/index.html#type-raw_backtrace">Stdlib.Printexc.raw_backtrace</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>poison_at stream exn bt</code> marks the stream as poisoned at the current position, which means that subsequent attempts to <a href="#val-push"><code>push</code></a> to the <code>stream</code> will raise the given exception with backtrace.</p><p>ℹ️ This operation is not cancelable.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-poison"><a href="#val-poison" class="anchor"></a><code><span><span class="keyword">val</span> poison : <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>exn <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>poison stream exn</code> is equivalent to <a href="#val-poison_at" title="poison_at"><code>poison_at stream exn (Printexc.get_callstack n)</code></a> where <code>n</code> defaults to <code>0</code>.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-cursor"><a href="#type-cursor" class="anchor"></a><code><span><span class="keyword">type</span> <span>!'a cursor</span></span></code></div><div class="spec-doc"><p>Represents a (past or current) position in a stream.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-tap"><a href="#val-tap" class="anchor"></a><code><span><span class="keyword">val</span> tap : <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="#type-cursor">cursor</a></span></span></code></div><div class="spec-doc"><p><code>tap stream</code> returns a <a href="#type-cursor"><code>cursor</code></a> to the current position of the <code>stream</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-peek_opt"><a href="#val-peek_opt" class="anchor"></a><code><span><span class="keyword">val</span> peek_opt : <span><span><span class="type-var">'a</span> <a href="#type-cursor">cursor</a></span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'a</span> * <span><span class="type-var">'a</span> <a href="#type-cursor">cursor</a></span>)</span> option</span></span></code></div><div class="spec-doc"><p><code>peek_opt cursor</code> immediately returns <code>Some (value, next)</code> with the <code>value</code> pushed to the position and a cursor to the <code>next</code> position, when the <code>cursor</code> points to a past position in the stream. Otherwise returns <code>None</code> or raises the exception that the stream was poisoned with.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read"><a href="#val-read" class="anchor"></a><code><span><span class="keyword">val</span> read : <span><span><span class="type-var">'a</span> <a href="#type-cursor">cursor</a></span> <span class="arrow">-></span></span> <span class="type-var">'a</span> * <span><span class="type-var">'a</span> <a href="#type-cursor">cursor</a></span></span></code></div><div class="spec-doc"><p><code>read cursor</code> immediately returns <code>(value, next)</code> with the <code>value</code> pushed to the position and a cursor to the <code>next</code> position, when the <code>cursor</code> points to a past position in the stream. If the <code>cursor</code> points to the current position of the stream, <code>read cursor</code> waits until a value is pushed to the stream or the stream is poisoned, in which case the exception that the stream was poisoned with will be raised.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read_evt"><a href="#val-read_evt" class="anchor"></a><code><span><span class="keyword">val</span> read_evt : <span><span><span class="type-var">'a</span> <a href="#type-cursor">cursor</a></span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'a</span> * <span><span class="type-var">'a</span> <a href="#type-cursor">cursor</a></span>)</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>read_evt cursor</code> returns an <span class="xref-unresolved" title="Event">event</span> that <a href="#val-read" title="read">reads</a> from the <code>cursor</code> position.</p></div></div></div></body></html>
|