ocaml-opentelemetry/eio/Eio_unix/Private/Thread_pool/index.html
2026-04-06 19:57:49 +00:00

8 lines
5 KiB
HTML
Raw Permalink 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>Thread_pool (eio.Eio_unix.Private.Thread_pool)</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> &#x00BB; <a href="../../../index.html">eio</a> &#x00BB; <a href="../../index.html">Eio_unix</a> &#x00BB; <a href="../index.html">Private</a> &#x00BB; Thread_pool</nav><header class="odoc-preamble"><h1>Module <code><span>Private.Thread_pool</span></code></h1><p>A pool of systhreads, to avoid the overhead of creating a new thread for each operation.</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> t</span></code></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="label">sleep_q</span>:<a href="../../../Eio_utils/Zzz/index.html#type-t">Eio_utils.Zzz.t</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>create ~sleep_q</code> is a new thread pool.</p><p><code>sleep_q</code> is used to register a clean-up task to finish idle threads.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-run"><a href="#val-run" class="anchor"></a><code><span><span class="keyword">val</span> run : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><span>(<span>unit <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p><code>run t fn</code> runs <code>fn ()</code> and then marks <code>t</code> as closed, releasing all idle threads.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-submit"><a href="#val-submit" class="anchor"></a><code><span><span class="keyword">val</span> submit :
<span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">ctx</span>:<a href="../../../Eio/Private/Fiber_context/index.html#type-t">Eio.Private.Fiber_context.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">enqueue</span>:<span>(<span><span><span>(<span class="type-var">'a</span>, <a href="../../../Eio/Exn/index.html#type-with_bt">Eio.Exn.with_bt</a>)</span> <a href="../../../../ocaml/Stdlib/index.html#type-result">result</a></span> <span class="arrow">&#45;&gt;</span></span> unit)</span> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<span>unit <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span>
unit</span></code></div><div class="spec-doc"><p><code>submit t ~ctx ~enqueue fn</code> starts running <code>fn</code> in a sys-thread, which uses <code>enqueue</code> to return the result.</p><p>If <code>ctx</code> is already cancelled then the error is passed to <code>enqueue</code> immediately. Systhreads do not respond to cancellation once running.</p></div></div><div class="odoc-spec"><div class="spec type extension anchored" id="extension-decl-Run_in_systhread"><a href="#extension-decl-Run_in_systhread" class="anchor"></a><code><span><span class="keyword">type</span> <a href="../../../../ocaml/Stdlib/Effect/index.html#type-t">Stdlib.Effect.t</a> += </span></code><ol><li id="extension-Run_in_systhread" class="def variant extension anchored"><a href="#extension-Run_in_systhread" class="anchor"></a><code><span>| </span><span><span class="extension">Run_in_systhread</span> : <span>(<span>unit <span class="arrow">&#45;&gt;</span></span>
<span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span> <span><span>(<span><span>(<span class="type-var">'a</span>, <a href="../../../Eio/Exn/index.html#type-with_bt">Eio.Exn.with_bt</a>)</span> <a href="../../../../ocaml/Stdlib/index.html#type-result">result</a></span> * <a href="#type-t">t</a>)</span> <a href="../../../../ocaml/Stdlib/Effect/index.html#type-t">Stdlib.Effect.t</a></span></span></code></li></ol></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-run_in_systhread"><a href="#val-run_in_systhread" class="anchor"></a><code><span><span class="keyword">val</span> run_in_systhread : <span><span class="optlabel">?label</span>:string <span class="arrow">&#45;&gt;</span></span> <span><span>(<span>unit <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span></span></code></div></div></div></body></html>