deploy: 7b3f6219955c21c477564fcf909d289a40fa09b1

This commit is contained in:
c-cube 2024-03-20 19:24:58 +00:00
parent 8774fcfc82
commit 08f86bbc5c
15 changed files with 65 additions and 15 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,29 @@
# 0.6
- breaking: remove `Immediate_runner` (bug prone and didn't
handle effects). `Moonpool_fib.main` can be used to handle
effects in the main function.
- remove deprecated alias `Moonpool.Pool`
- feat: add structured concurrency sub-library `moonpool.fib` with
fibers. Fibers can use `await` and spawn other fibers that will
be appropriately cancelled when their parent is.
- feat: add add `moonpool-lwt` as an experimental bridge between moonpool and lwt.
This allows moonpool runners to be used from within Lwt to
perform background computations, and conversely to call Lwt from
moonpool with some precautions.
- feat: task-local storage in the main moonpool runners, available from
fibers and regular tasks.
- feat: add `Exn_bt` to core
- feat: add `Runner.dummy`
- make `moonpool.forkjoin` optional (only on OCaml >= 5.0)
- feat: add `Fut.Advanced.barrier_on_abstract_container_of_futures`
- feat: add `Fut.map_list`
- refactor: split off domain pool to `moonpool.dpool`
- fix too early exit in Ws_pool
# 0.5.1
- fix `Ws_pool`: workers would exit before processing

File diff suppressed because one or more lines are too long

View file

@ -1,2 +1,2 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Exn_bt (moonpool.Moonpool.Exn_bt)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><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">moonpool</a> &#x00BB; <a href="../index.html">Moonpool</a> &#x00BB; Exn_bt</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool.Exn_bt</span></code></h1><p>Exception with backtrace.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> NEXT_RELEASE</li></ul></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><span> = exn * <a href="../../../ocaml/Stdlib/Printexc/index.html#type-raw_backtrace">Stdlib.Printexc.raw_backtrace</a></span></code></div><div class="spec-doc"><p>An exception bundled with a backtrace</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-exn"><a href="#val-exn" class="anchor"></a><code><span><span class="keyword">val</span> exn : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> exn</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bt"><a href="#val-bt" class="anchor"></a><code><span><span class="keyword">val</span> bt : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="../../../ocaml/Stdlib/Printexc/index.html#type-raw_backtrace">Stdlib.Printexc.raw_backtrace</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-make"><a href="#val-make" class="anchor"></a><code><span><span class="keyword">val</span> make : <span>exn <span class="arrow">&#45;&gt;</span></span> <span><a href="../../../ocaml/Stdlib/Printexc/index.html#type-raw_backtrace">Stdlib.Printexc.raw_backtrace</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Trivial builder</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get"><a href="#val-get" class="anchor"></a><code><span><span class="keyword">val</span> get : <span>exn <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>get exn</code> is <code>make exn (get_raw_backtrace ())</code></p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_callstack"><a href="#val-get_callstack" class="anchor"></a><code><span><span class="keyword">val</span> get_callstack : <span>int <span class="arrow">&#45;&gt;</span></span> <span>exn <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-raise"><a href="#val-raise" class="anchor"></a><code><span><span class="keyword">val</span> raise : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p>Raise the exception with its save backtrace</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-show"><a href="#val-show" class="anchor"></a><code><span><span class="keyword">val</span> show : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Simple printing</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-result"><a href="#type-result" class="anchor"></a><code><span><span class="keyword">type</span> <span class="keyword">nonrec</span> <span>'a result</span></span><span> = <span><span>(<span class="type-var">'a</span>, <a href="#type-t">t</a>)</span> <a href="../../../ocaml/Stdlib/index.html#type-result">result</a></span></span></code></div></div></div></body></html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Exn_bt (moonpool.Moonpool.Exn_bt)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><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">moonpool</a> &#x00BB; <a href="../index.html">Moonpool</a> &#x00BB; Exn_bt</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool.Exn_bt</span></code></h1><p>Exception with backtrace.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.6</li></ul></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><span> = exn * <a href="../../../ocaml/Stdlib/Printexc/index.html#type-raw_backtrace">Stdlib.Printexc.raw_backtrace</a></span></code></div><div class="spec-doc"><p>An exception bundled with a backtrace</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-exn"><a href="#val-exn" class="anchor"></a><code><span><span class="keyword">val</span> exn : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> exn</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bt"><a href="#val-bt" class="anchor"></a><code><span><span class="keyword">val</span> bt : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="../../../ocaml/Stdlib/Printexc/index.html#type-raw_backtrace">Stdlib.Printexc.raw_backtrace</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-make"><a href="#val-make" class="anchor"></a><code><span><span class="keyword">val</span> make : <span>exn <span class="arrow">&#45;&gt;</span></span> <span><a href="../../../ocaml/Stdlib/Printexc/index.html#type-raw_backtrace">Stdlib.Printexc.raw_backtrace</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Trivial builder</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get"><a href="#val-get" class="anchor"></a><code><span><span class="keyword">val</span> get : <span>exn <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>get exn</code> is <code>make exn (get_raw_backtrace ())</code></p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_callstack"><a href="#val-get_callstack" class="anchor"></a><code><span><span class="keyword">val</span> get_callstack : <span>int <span class="arrow">&#45;&gt;</span></span> <span>exn <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-raise"><a href="#val-raise" class="anchor"></a><code><span><span class="keyword">val</span> raise : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p>Raise the exception with its save backtrace</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-show"><a href="#val-show" class="anchor"></a><code><span><span class="keyword">val</span> show : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Simple printing</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-result"><a href="#type-result" class="anchor"></a><code><span><span class="keyword">type</span> <span class="keyword">nonrec</span> <span>'a result</span></span><span> = <span><span>(<span class="type-var">'a</span>, <a href="#type-t">t</a>)</span> <a href="../../../ocaml/Stdlib/index.html#type-result">result</a></span></span></code></div></div></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,2 +1,2 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Immediate_runner (moonpool.Moonpool.Immediate_runner)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><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">moonpool</a> &#x00BB; <a href="../index.html">Moonpool</a> &#x00BB; Immediate_runner</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool.Immediate_runner</span></code></h1><p>Runner that runs tasks in the caller thread.</p><p>This is removed since NEXT_RELEASE, and replaced by <a href="../../Moonpool_fib/Main/index.html"><code>Moonpool_fib.Main</code></a>.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> use Moonpool_fib.Main</li></ul></header><div class="odoc-content"></div></body></html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Immediate_runner (moonpool.Moonpool.Immediate_runner)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><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">moonpool</a> &#x00BB; <a href="../index.html">Moonpool</a> &#x00BB; Immediate_runner</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool.Immediate_runner</span></code></h1><p>Runner that runs tasks in the caller thread.</p><p>This is removed since 0.6, and replaced by <a href="../../Moonpool_fib/Main/index.html"><code>Moonpool_fib.Main</code></a>.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> use Moonpool_fib.Main</li></ul></header><div class="odoc-content"></div></body></html>

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Task_local_storage (moonpool.Moonpool.Task_local_storage)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><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">moonpool</a> &#x00BB; <a href="../index.html">Moonpool</a> &#x00BB; Task_local_storage</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool.Task_local_storage</span></code></h1><p>Task-local storage.</p><p>This storage is associated to the current task, just like thread-local storage is associated with the current thread. The storage is carried along in case the current task is suspended.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> NEXT_RELEASE</li></ul></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><span> = <span class="xref-unresolved">Moonpool__</span>.Types_.local_storage</span></code></div><div class="spec-doc"><p>Underlying storage for a task. This is mutable and not thread-safe.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-dummy"><a href="#val-dummy" class="anchor"></a><code><span><span class="keyword">val</span> dummy : <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-key"><a href="#type-key" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a key</span></span></code></div><div class="spec-doc"><p>A key used to access a particular (typed) storage slot on every task.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-new_key"><a href="#val-new_key" class="anchor"></a><code><span><span class="keyword">val</span> new_key : <span><span class="label">init</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>unit <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="#type-key">key</a></span></span></code></div><div class="spec-doc"><p><code>new_key ~init ()</code> makes a new key. Keys are expensive and should never be allocated dynamically or in a loop. The correct pattern is, at toplevel:</p><pre class="language-ocaml"><code> let k_foo : foo Task_ocal_storage.key =
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Task_local_storage (moonpool.Moonpool.Task_local_storage)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><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">moonpool</a> &#x00BB; <a href="../index.html">Moonpool</a> &#x00BB; Task_local_storage</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool.Task_local_storage</span></code></h1><p>Task-local storage.</p><p>This storage is associated to the current task, just like thread-local storage is associated with the current thread. The storage is carried along in case the current task is suspended.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.6</li></ul></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><span> = <span class="xref-unresolved">Moonpool__</span>.Types_.local_storage</span></code></div><div class="spec-doc"><p>Underlying storage for a task. This is mutable and not thread-safe.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-dummy"><a href="#val-dummy" class="anchor"></a><code><span><span class="keyword">val</span> dummy : <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-key"><a href="#type-key" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a key</span></span></code></div><div class="spec-doc"><p>A key used to access a particular (typed) storage slot on every task.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-new_key"><a href="#val-new_key" class="anchor"></a><code><span><span class="keyword">val</span> new_key : <span><span class="label">init</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>unit <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="#type-key">key</a></span></span></code></div><div class="spec-doc"><p><code>new_key ~init ()</code> makes a new key. Keys are expensive and should never be allocated dynamically or in a loop. The correct pattern is, at toplevel:</p><pre class="language-ocaml"><code> let k_foo : foo Task_ocal_storage.key =
Task_local_storage.new_key ~init:(fun () -&gt; make_foo ()) ()
(* … *)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,2 +1,2 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Moonpool_dpool (moonpool.Moonpool_dpool)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><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">moonpool</a> &#x00BB; Moonpool_dpool</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_dpool</span></code></h1><p>Static pool of domains.</p><p>These domains are shared between <b>all</b> the pools in moonpool. The rationale is that we should not have more domains than cores, so it's easier to reserve exactly that many domain slots, and run more flexible thread pools on top (each domain being shared by potentially multiple threads from multiple pools).</p><p>The pool should not contain actual domains if it's not in use, ie if no runner is presently actively using one or more of the domain slots.</p><p><b>NOTE</b>: Interface is still experimental.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> NEXT_RELEASE</li></ul></header><nav class="odoc-toc"><ul><li><a href="#low-level-interface-for-resouce-handling">Low level interface for resouce handling</a></li></ul></nav><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-domain"><a href="#type-domain" class="anchor"></a><code><span><span class="keyword">type</span> domain</span><span> = <a href="../Moonpool_private/Domain_/index.html#type-t">Moonpool_private.Domain_.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-max_number_of_domains"><a href="#val-max_number_of_domains" class="anchor"></a><code><span><span class="keyword">val</span> max_number_of_domains : <span>unit <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p>Number of domains in the pool when all domains are active.</p></div></div><h3 id="low-level-interface-for-resouce-handling"><a href="#low-level-interface-for-resouce-handling" class="anchor"></a>Low level interface for resouce handling</h3><p>Be very cautious with this interface, or resource leaks might occur.</p><div class="odoc-spec"><div class="spec value anchored" id="val-run_on"><a href="#val-run_on" class="anchor"></a><code><span><span class="keyword">val</span> run_on : <span>int <span class="arrow">&#45;&gt;</span></span> <span><span>(<span>unit <span class="arrow">&#45;&gt;</span></span> unit)</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>run_on i f</code> runs <code>f()</code> on the domain with index <code>i</code>. Precondition: <code>0 &lt;= i &lt; n_domains()</code>. The thread must call <a href="#val-decr_on"><code>decr_on</code></a> with <code>i</code> once it's done.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-decr_on"><a href="#val-decr_on" class="anchor"></a><code><span><span class="keyword">val</span> decr_on : <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Signal that a thread is stopping on the domain with index <code>i</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-run_on_and_wait"><a href="#val-run_on_and_wait" class="anchor"></a><code><span><span class="keyword">val</span> run_on_and_wait : <span>int <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_on_and_wait i f</code> runs <code>f()</code> on the domain with index <code>i</code>, and blocks until the result of <code>f()</code> is returned back.</p></div></div></div></body></html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Moonpool_dpool (moonpool.Moonpool_dpool)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><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">moonpool</a> &#x00BB; Moonpool_dpool</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_dpool</span></code></h1><p>Static pool of domains.</p><p>These domains are shared between <b>all</b> the pools in moonpool. The rationale is that we should not have more domains than cores, so it's easier to reserve exactly that many domain slots, and run more flexible thread pools on top (each domain being shared by potentially multiple threads from multiple pools).</p><p>The pool should not contain actual domains if it's not in use, ie if no runner is presently actively using one or more of the domain slots.</p><p><b>NOTE</b>: Interface is still experimental.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.6</li></ul></header><nav class="odoc-toc"><ul><li><a href="#low-level-interface-for-resouce-handling">Low level interface for resouce handling</a></li></ul></nav><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-domain"><a href="#type-domain" class="anchor"></a><code><span><span class="keyword">type</span> domain</span><span> = <a href="../Moonpool_private/Domain_/index.html#type-t">Moonpool_private.Domain_.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-max_number_of_domains"><a href="#val-max_number_of_domains" class="anchor"></a><code><span><span class="keyword">val</span> max_number_of_domains : <span>unit <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p>Number of domains in the pool when all domains are active.</p></div></div><h3 id="low-level-interface-for-resouce-handling"><a href="#low-level-interface-for-resouce-handling" class="anchor"></a>Low level interface for resouce handling</h3><p>Be very cautious with this interface, or resource leaks might occur.</p><div class="odoc-spec"><div class="spec value anchored" id="val-run_on"><a href="#val-run_on" class="anchor"></a><code><span><span class="keyword">val</span> run_on : <span>int <span class="arrow">&#45;&gt;</span></span> <span><span>(<span>unit <span class="arrow">&#45;&gt;</span></span> unit)</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>run_on i f</code> runs <code>f()</code> on the domain with index <code>i</code>. Precondition: <code>0 &lt;= i &lt; n_domains()</code>. The thread must call <a href="#val-decr_on"><code>decr_on</code></a> with <code>i</code> once it's done.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-decr_on"><a href="#val-decr_on" class="anchor"></a><code><span><span class="keyword">val</span> decr_on : <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Signal that a thread is stopping on the domain with index <code>i</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-run_on_and_wait"><a href="#val-run_on_and_wait" class="anchor"></a><code><span><span class="keyword">val</span> run_on_and_wait : <span>int <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_on_and_wait i f</code> runs <code>f()</code> on the domain with index <code>i</code>, and blocks until the result of <code>f()</code> is returned back.</p></div></div></div></body></html>

View file

@ -1,2 +1,2 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Main (moonpool.Moonpool_fib.Main)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><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">moonpool</a> &#x00BB; <a href="../index.html">Moonpool_fib</a> &#x00BB; Main</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_fib.Main</span></code></h1><p>Main thread.</p><p>This is evolved from <code>Moonpool.Immediate_runner</code>, but unlike it, this API assumes you run it in a thread (possibly the main thread) which will block until the initial computation is done.</p><p>This means it's reasonable to use <code>Main.main (fun () -&gt; do_everything)</code> at the beginning of the program. Other Moonpool pools can be created for background tasks, etc. to do the heavy lifting, and the main thread (inside this immediate runner) can coordinate tasks via <code>Fiber.await</code>.</p><p>Aside from the fact that this blocks the caller thread, it is fairly similar to <code>Background_thread</code> in that there's a single worker to process tasks/fibers.</p><p>This handles effects, including the ones in <a href="../Fiber/index.html"><code>Fiber</code></a>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> NEXT_RELEASE</li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-main"><a href="#val-main" class="anchor"></a><code><span><span class="keyword">val</span> main : <span><span>(<span><a href="../../Moonpool/Runner/index.html#type-t">Moonpool.Runner.t</a> <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>main f</code> runs <code>f()</code> in a scope that handles effects, including <a href="../Fiber/index.html#val-await"><code>Fiber.await</code></a>.</p><p>This scope can run background tasks as well, in a cooperative fashion.</p></div></div></div></body></html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Main (moonpool.Moonpool_fib.Main)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><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">moonpool</a> &#x00BB; <a href="../index.html">Moonpool_fib</a> &#x00BB; Main</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_fib.Main</span></code></h1><p>Main thread.</p><p>This is evolved from <code>Moonpool.Immediate_runner</code>, but unlike it, this API assumes you run it in a thread (possibly the main thread) which will block until the initial computation is done.</p><p>This means it's reasonable to use <code>Main.main (fun () -&gt; do_everything)</code> at the beginning of the program. Other Moonpool pools can be created for background tasks, etc. to do the heavy lifting, and the main thread (inside this immediate runner) can coordinate tasks via <code>Fiber.await</code>.</p><p>Aside from the fact that this blocks the caller thread, it is fairly similar to <code>Background_thread</code> in that there's a single worker to process tasks/fibers.</p><p>This handles effects, including the ones in <a href="../Fiber/index.html"><code>Fiber</code></a>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.6</li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-main"><a href="#val-main" class="anchor"></a><code><span><span class="keyword">val</span> main : <span><span>(<span><a href="../../Moonpool/Runner/index.html#type-t">Moonpool.Runner.t</a> <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>main f</code> runs <code>f()</code> in a scope that handles effects, including <a href="../Fiber/index.html#val-await"><code>Fiber.await</code></a>.</p><p>This scope can run background tasks as well, in a cooperative fashion.</p></div></div></div></body></html>

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,29 @@
# 0.6
- breaking: remove `Immediate_runner` (bug prone and didn't
handle effects). `Moonpool_fib.main` can be used to handle
effects in the main function.
- remove deprecated alias `Moonpool.Pool`
- feat: add structured concurrency sub-library `moonpool.fib` with
fibers. Fibers can use `await` and spawn other fibers that will
be appropriately cancelled when their parent is.
- feat: add add `moonpool-lwt` as an experimental bridge between moonpool and lwt.
This allows moonpool runners to be used from within Lwt to
perform background computations, and conversely to call Lwt from
moonpool with some precautions.
- feat: task-local storage in the main moonpool runners, available from
fibers and regular tasks.
- feat: add `Exn_bt` to core
- feat: add `Runner.dummy`
- make `moonpool.forkjoin` optional (only on OCaml >= 5.0)
- feat: add `Fut.Advanced.barrier_on_abstract_container_of_futures`
- feat: add `Fut.map_list`
- refactor: split off domain pool to `moonpool.dpool`
- fix too early exit in Ws_pool
# 0.5.1
- fix `Ws_pool`: workers would exit before processing