mirror of
https://github.com/c-cube/nanoev.git
synced 2025-12-08 04:05:48 -05:00
7 lines
5.7 KiB
HTML
7 lines
5.7 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Handler (picos.Picos.Handler)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.0.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</a> » <a href="../index.html">Picos</a> » Handler</nav><header class="odoc-preamble"><h1>Module <code><span>Picos.Handler</span></code></h1><p>Handler for the effects based operations of Picos for OCaml 4.</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>'c t</span></span><span> = </span><span>{</span></code><ol><li id="type-t.current" class="def record field anchored"><a href="#type-t.current" class="anchor"></a><code><span>current : <span><span class="type-var">'c</span> <span class="arrow">-></span></span> <a href="../Fiber/index.html#type-t">Fiber.t</a>;</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>See <a href="../Fiber/index.html#val-current"><code>Picos.Fiber.current</code></a>.</p><span class="comment-delim">*)</span></div></li><li id="type-t.spawn" class="def record field anchored"><a href="#type-t.spawn" class="anchor"></a><code><span>spawn : <span><span class="type-var">'c</span> <span class="arrow">-></span></span> <span><a href="../Fiber/index.html#type-t">Fiber.t</a> <span class="arrow">-></span></span> <span><span>(<span><a href="../Fiber/index.html#type-t">Fiber.t</a> <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span> unit;</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>See <a href="../Fiber/index.html#val-spawn"><code>Picos.Fiber.spawn</code></a>.</p><span class="comment-delim">*)</span></div></li><li id="type-t.yield" class="def record field anchored"><a href="#type-t.yield" class="anchor"></a><code><span>yield : <span><span class="type-var">'c</span> <span class="arrow">-></span></span> unit;</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>See <a href="../Fiber/index.html#val-yield"><code>Picos.Fiber.yield</code></a>.</p><span class="comment-delim">*)</span></div></li><li id="type-t.cancel_after" class="def record field anchored"><a href="#type-t.cancel_after" class="anchor"></a><code><span>cancel_after : 'a. <span><span class="type-var">'c</span> <span class="arrow">-></span></span>
|
||
<span><span><span class="type-var">'a</span> <a href="../Computation/index.html#type-t">Computation.t</a></span> <span class="arrow">-></span></span>
|
||
<span><span class="label">seconds</span>:float <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 class="def-doc"><span class="comment-delim">(*</span><p>See <a href="../Computation/index.html#val-cancel_after"><code>Picos.Computation.cancel_after</code></a>.</p><span class="comment-delim">*)</span></div></li><li id="type-t.await" class="def record field anchored"><a href="#type-t.await" class="anchor"></a><code><span>await : <span><span class="type-var">'c</span> <span class="arrow">-></span></span> <span><a href="../Trigger/index.html#type-t">Trigger.t</a> <span class="arrow">-></span></span> <span><span>(exn * <a href="../../../ocaml/Stdlib/Printexc/index.html#type-raw_backtrace">Stdlib.Printexc.raw_backtrace</a>)</span> option</span>;</span></code><div class="def-doc"><span class="comment-delim">(*</span><p>See <a href="../Trigger/index.html#val-await"><code>Picos.Trigger.await</code></a>.</p><span class="comment-delim">*)</span></div></li></ol><code><span>}</span></code></div><div class="spec-doc"><p>A record of implementations of the primitive effects based operations of Picos. The operations take a context of type <code>'c</code> as an argument.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-using"><a href="#val-using" class="anchor"></a><code><span><span class="keyword">val</span> using : <span><span><span class="type-var">'c</span> <a href="#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'c</span> <span class="arrow">-></span></span> <span><span>(<span><a href="../Fiber/index.html#type-t">Fiber.t</a> <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>using handler context main</code> sets the <code>handler</code> and the <code>context</code> for the handler of the primitive effects based operations of Picos while running <code>main</code>.</p><p>ℹ️ The behavior is that</p><ul><li>on OCaml 4, <code>using</code> stores the <code>handler</code> in <a href="../../Picos_thread/TLS/index.html" title="Picos_thread.TLS"><code>TLS</code></a>, which allows the operations to be accessed during the execution of the <code>thunk</code>, and</li><li>on OCaml 5, <code>using</code> runs <code>thunk</code> with a deep effect handler that delegates to the operations of the <code>handler</code>.</li></ul><p>⚠️ While this works on OCaml 5, you usually want to use a scheduler that implements an effect handler directly, because that is likely to perform better.</p></div></div></div></body></html>
|