mirror of
https://github.com/c-cube/moonpool.git
synced 2026-01-27 19:54:50 -05:00
deploy: df8b284a0d
This commit is contained in:
parent
9d4febe5f7
commit
41b180fdef
109 changed files with 3030 additions and 61 deletions
|
|
@ -1,2 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html><head><meta charset="utf-8"><meta name="generator" content="odig v0.0.9"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" media="screen, print" href="_odoc-theme/odoc.css"><title>_opam</title></head><body class="odoc"><nav class="odoc-nav">🐫</nav><header class="odoc-preamble"><h1>OCaml package documentation</h1><p>Browse <a href="#by-name">by name</a>, <a href="#by-tag">by tag</a>, the <a href="ocaml/Stdlib/index.html#modules">standard library</a> and the <a href="https://ocaml.org/manual/">OCaml manual</a> (online, latest version).</p><p><small>Generated for <code>/home/runner/work/moonpool/moonpool/_opam/lib</code></small></p></header><nav class="odoc-toc"><ul><li><a href="ocaml/Stdlib/index.html#modules">OCaml standard library</a></li><li><a href="https://ocaml.org/manual/">OCaml manual</a></li><li><a href="#by-name">Packages by name</a></li><li><a href="#by-tag">Packages by tag</a></li></ul></nav><div class="odoc-content"><h2 id="by-name"><a href="#by-name" aria-hidden="true" class="anchor"></a>Packages by name</h2><div class="by-name"><nav><a href="#name-e">e</a><a href="#name-m">m</a><a href="#name-o">o</a></nav><h3 id="name-e"><a href="#name-e" aria-hidden="true" class="anchor"></a>e</h3><ol class="packages"><li id="package-either"><a href="#package-either" aria-hidden="true" class="anchor"></a><a href="either/index.html">either</a> <span class="version"></span> <span class="synopsis"></span></li></ol><h3 id="name-m"><a href="#name-m" aria-hidden="true" class="anchor"></a>m</h3><ol class="packages"><li id="package-moonpool"><a href="#package-moonpool" aria-hidden="true" class="anchor"></a><a href="moonpool/index.html">moonpool</a> <span class="version"></span> <span class="synopsis"></span></li></ol><h3 id="name-o"><a href="#name-o" aria-hidden="true" class="anchor"></a>o</h3><ol class="packages"><li id="package-ocaml"><a href="#package-ocaml" aria-hidden="true" class="anchor"></a><a href="ocaml/index.html">ocaml</a> <span class="version"></span> <span class="synopsis"></span></li></ol></div><h2 id="by-tag"><a href="#by-tag" aria-hidden="true" class="anchor"></a>Packages by tag</h2><div class="by-tag"><nav><table></table></nav></div></div></body></html>
|
||||
<html><head><meta charset="utf-8"><meta name="generator" content="odig v0.0.9"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" media="screen, print" href="_odoc-theme/odoc.css"><title>_opam</title></head><body class="odoc"><nav class="odoc-nav">🐫</nav><header class="odoc-preamble"><h1>OCaml package documentation</h1><p>Browse <a href="#by-name">by name</a>, <a href="#by-tag">by tag</a>, the <a href="ocaml/Stdlib/index.html#modules">standard library</a> and the <a href="https://ocaml.org/manual/">OCaml manual</a> (online, latest version).</p><p><small>Generated for <code>/home/runner/work/moonpool/moonpool/_opam/lib</code></small></p></header><nav class="odoc-toc"><ul><li><a href="ocaml/Stdlib/index.html#modules">OCaml standard library</a></li><li><a href="https://ocaml.org/manual/">OCaml manual</a></li><li><a href="#by-name">Packages by name</a></li><li><a href="#by-tag">Packages by tag</a></li></ul></nav><div class="odoc-content"><h2 id="by-name"><a href="#by-name" aria-hidden="true" class="anchor"></a>Packages by name</h2><div class="by-name"><nav><a href="#name-e">e</a><a href="#name-l">l</a><a href="#name-m">m</a><a href="#name-o">o</a></nav><h3 id="name-e"><a href="#name-e" aria-hidden="true" class="anchor"></a>e</h3><ol class="packages"><li id="package-either"><a href="#package-either" aria-hidden="true" class="anchor"></a><a href="either/index.html">either</a> <span class="version"></span> <span class="synopsis"></span></li></ol><h3 id="name-l"><a href="#name-l" aria-hidden="true" class="anchor"></a>l</h3><ol class="packages"><li id="package-lwt"><a href="#package-lwt" aria-hidden="true" class="anchor"></a><a href="lwt/index.html">lwt</a> <span class="version"></span> <span class="synopsis"></span></li></ol><h3 id="name-m"><a href="#name-m" aria-hidden="true" class="anchor"></a>m</h3><ol class="packages"><li id="package-moonpool"><a href="#package-moonpool" aria-hidden="true" class="anchor"></a><a href="moonpool/index.html">moonpool</a> <span class="version"></span> <span class="synopsis"></span></li><li id="package-moonpool-lwt"><a href="#package-moonpool-lwt" aria-hidden="true" class="anchor"></a><a href="moonpool-lwt/index.html">moonpool-lwt</a> <span class="version"></span> <span class="synopsis"></span></li></ol><h3 id="name-o"><a href="#name-o" aria-hidden="true" class="anchor"></a>o</h3><ol class="packages"><li id="package-ocaml"><a href="#package-ocaml" aria-hidden="true" class="anchor"></a><a href="ocaml/index.html">ocaml</a> <span class="version"></span> <span class="synopsis"></span></li></ol></div><h2 id="by-tag"><a href="#by-tag" aria-hidden="true" class="anchor"></a>Packages by tag</h2><div class="by-tag"><nav><table></table></nav></div></div></body></html>
|
||||
2
dev/lwt/Lwt/Exception_filter/index.html
Normal file
2
dev/lwt/Lwt/Exception_filter/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Exception_filter (lwt.Lwt.Exception_filter)</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">lwt</a> » <a href="../index.html">Lwt</a> » Exception_filter</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt.Exception_filter</span></code></h1></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 class="spec-doc"><p>An <code>Exception_filter.t</code> is a value which indicates to Lwt what exceptions to catch and what exceptions to let bubble up all the way out of the main loop immediately.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-handle_all"><a href="#val-handle_all" class="anchor"></a><code><span><span class="keyword">val</span> handle_all : <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>handle_all</code> is the default filter. With it the all the exceptions (including <code>Out_of_memory</code> and <code>Stack_overflow</code>) can be handled: caught and transformed into rejected promises.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-handle_all_except_runtime"><a href="#val-handle_all_except_runtime" class="anchor"></a><code><span><span class="keyword">val</span> handle_all_except_runtime : <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>handle_all_except_runtime</code> is a filter which lets the OCaml runtime exceptions (<code>Out_of_memory</code> and <code>Stack_overflow</code>) go through all the Lwt abstractions and bubble all the way out of the call to <code>Lwt_main.run</code>.</p><p>Note that if you set this handler, then the runtime exceptions leave the Lwt internal state inconsistent. For this reason, you will not be able to call <code>Lwt_main.run</code> again after such an exception has escaped <code>Lwt_main.run</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-set"><a href="#val-set" class="anchor"></a><code><span><span class="keyword">val</span> set : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>set</code> sets the given exception filter globally. You should call this function at most once during the start of your program, before the first call to <code>Lwt_main.run</code>.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt/Infix/Let_syntax/Open_on_rhs/index.html
Normal file
2
dev/lwt/Lwt/Infix/Let_syntax/Open_on_rhs/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Open_on_rhs (lwt.Lwt.Infix.Let_syntax.Open_on_rhs)</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">lwt</a> » <a href="../../../index.html">Lwt</a> » <a href="../../index.html">Infix</a> » <a href="../index.html">Let_syntax</a> » Open_on_rhs</nav><header class="odoc-preamble"><h1>Module <code><span>Let_syntax.Open_on_rhs</span></code></h1></header><div class="odoc-content"></div></body></html>
|
||||
2
dev/lwt/Lwt/Infix/Let_syntax/index.html
Normal file
2
dev/lwt/Lwt/Infix/Let_syntax/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Let_syntax (lwt.Lwt.Infix.Let_syntax)</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">lwt</a> » <a href="../../index.html">Lwt</a> » <a href="../index.html">Infix</a> » Let_syntax</nav><header class="odoc-preamble"><h1>Module <code><span>Infix.Let_syntax</span></code></h1><p>This module provides support for <a href="https://github.com/janestreet/ppx_let">ppx_let</a>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.2.0</li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-return"><a href="#val-return" class="anchor"></a><code><span><span class="keyword">val</span> return : <span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-return"><code>Lwt.return</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-map"><a href="#val-map" class="anchor"></a><code><span><span class="keyword">val</span> map : <span><span><span class="type-var">'a</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="label">f</span>:<span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-map"><code>Lwt.map</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bind"><a href="#val-bind" class="anchor"></a><code><span><span class="keyword">val</span> bind : <span><span><span class="type-var">'a</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="label">f</span>:<span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../../index.html#type-t">t</a></span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-bind"><code>Lwt.bind</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-both"><a href="#val-both" class="anchor"></a><code><span><span class="keyword">val</span> both : <span><span><span class="type-var">'a</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span><span class="type-var">'b</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>)</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-both"><code>Lwt.both</code></a>.</p></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Open_on_rhs"><a href="#module-Open_on_rhs" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Open_on_rhs/index.html">Open_on_rhs</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div></div></body></html>
|
||||
14
dev/lwt/Lwt/Infix/index.html
Normal file
14
dev/lwt/Lwt/Infix/index.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Infix (lwt.Lwt.Infix)</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">lwt</a> » <a href="../index.html">Lwt</a> » Infix</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt.Infix</span></code></h1><p>This module provides several infix operators for making programming with Lwt more convenient.</p><p>To use it, open <code>Lwt.Infix</code>.</p><p>Of the operators declared in this module, only <code>>|=</code> is recommended for new code. The only other commonly-used operator is <code>>>=</code>.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-(>>=)"><a href="#val-(>>=)" class="anchor"></a><code><span><span class="keyword">val</span> (>>=) : <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>p >>= f</code> is the same as <a href="../index.html#val-bind"><code>Lwt.bind</code></a><code> p f</code>. It requires <code>Lwt.Infix</code> to be opened in scope:</p><pre class="language-ocaml"><code>open Lwt.Infix
|
||||
|
||||
let () =
|
||||
Lwt_main.run
|
||||
(Lwt_io.(read_line stdin) >>= Lwt_io.printl)
|
||||
|
||||
(* ocamlfind opt -linkpkg -thread -package lwt.unix code.ml && ./a.out *)</code></pre><p>It is recommended to use the PPX <code>let%lwt</code> syntax instead. This operator is the next-best choice. It is frequently found while reading existing Lwt code.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(>|=)"><a href="#val-(>|=)" class="anchor"></a><code><span><span class="keyword">val</span> (>|=) : <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>p >|= f</code> is the same as <a href="../index.html#val-map"><code>Lwt.map</code></a><code> f p</code>. It requires <code>Lwt.Infix</code> to be opened in scope.</p><pre class="language-ocaml"><code>open Lwt.Infix
|
||||
|
||||
let () =
|
||||
Lwt_main.run
|
||||
(Lwt_io.(read_line stdin) >|= ignore)
|
||||
|
||||
(* ocamlfind opt -linkpkg -thread -package lwt.unix code.ml && ./a.out *)</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(<&>)"><a href="#val-(<&>)" class="anchor"></a><code><span><span class="keyword">val</span> (<&>) : <span><span>unit <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>unit <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span>unit <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>p1 <&> p2</code> is the same as <a href="../index.html#val-join"><code>Lwt.join</code></a><code> [p1; p2]</code>. It requires <code>Lwt.Infix</code> to be opened in scope.</p><p>Unlike with <a href="../index.html#val-bind"><code>Lwt.bind</code></a> and <a href="../index.html#val-map"><code>Lwt.map</code></a>, there are no problems with explicit <a href="../index.html#val-join"><code>Lwt.join</code></a> syntax, so using this operator is not recommended.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(<?>)"><a href="#val-(<?>)" class="anchor"></a><code><span><span class="keyword">val</span> (<?>) : <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>p1 <?> p2</code> is the same as <a href="../index.html#val-choose"><code>Lwt.choose</code></a><code> [p1; p2]</code>. It requires <code>Lwt.Infix</code> to be opened in scope.</p><p>Unlike with <a href="../index.html#val-bind"><code>Lwt.bind</code></a> and <a href="../index.html#val-map"><code>Lwt.map</code></a>, there are no problems with explicit <a href="../index.html#val-choose"><code>Lwt.choose</code></a> syntax, so using this operator is not recommended.</p><p>Furthermore, most users actually need <a href="../index.html#val-pick"><code>Lwt.pick</code></a> instead of <a href="../index.html#val-choose"><code>Lwt.choose</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(=<<)"><a href="#val-(=<<)" class="anchor"></a><code><span><span class="keyword">val</span> (=<<) : <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span>)</span> <span class="arrow">-></span></span> <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>f =<< p</code> is the same as <a href="../index.html#val-bind"><code>Lwt.bind</code></a><code> p f</code>. It requires <code>Lwt.Infix</code> to be opened in scope.</p><p>This operator is obscure and its use is discouraged. It is the same as <code>p >>= f</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(=|<)"><a href="#val-(=|<)" class="anchor"></a><code><span><span class="keyword">val</span> (=|<) : <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>f =|< p</code> is the same as <a href="../index.html#val-map"><code>Lwt.map</code></a><code> f p</code>. It requires <code>Lwt.Infix</code> to be opened in scope.</p><p>This operator is obscure and its use is discouraged. It is the same as <code>p >|= f</code>.</p></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Let_syntax"><a href="#module-Let_syntax" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Let_syntax/index.html">Let_syntax</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>This module provides support for <a href="https://github.com/janestreet/ppx_let">ppx_let</a>.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt/Let_syntax/Let_syntax/Open_on_rhs/index.html
Normal file
2
dev/lwt/Lwt/Let_syntax/Let_syntax/Open_on_rhs/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Open_on_rhs (lwt.Lwt.Let_syntax.Let_syntax.Open_on_rhs)</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">lwt</a> » <a href="../../../index.html">Lwt</a> » <a href="../../index.html">Let_syntax</a> » <a href="../index.html">Let_syntax</a> » Open_on_rhs</nav><header class="odoc-preamble"><h1>Module <code><span>Let_syntax.Open_on_rhs</span></code></h1></header><div class="odoc-content"></div></body></html>
|
||||
2
dev/lwt/Lwt/Let_syntax/Let_syntax/index.html
Normal file
2
dev/lwt/Lwt/Let_syntax/Let_syntax/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Let_syntax (lwt.Lwt.Let_syntax.Let_syntax)</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">lwt</a> » <a href="../../index.html">Lwt</a> » <a href="../index.html">Let_syntax</a> » Let_syntax</nav><header class="odoc-preamble"><h1>Module <code><span>Let_syntax.Let_syntax</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-return"><a href="#val-return" class="anchor"></a><code><span><span class="keyword">val</span> return : <span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-return"><code>Lwt.return</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-map"><a href="#val-map" class="anchor"></a><code><span><span class="keyword">val</span> map : <span><span><span class="type-var">'a</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="label">f</span>:<span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-map"><code>Lwt.map</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bind"><a href="#val-bind" class="anchor"></a><code><span><span class="keyword">val</span> bind : <span><span><span class="type-var">'a</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="label">f</span>:<span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../../index.html#type-t">t</a></span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-bind"><code>Lwt.bind</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-both"><a href="#val-both" class="anchor"></a><code><span><span class="keyword">val</span> both : <span><span><span class="type-var">'a</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span><span class="type-var">'b</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>)</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-both"><code>Lwt.both</code></a>.</p></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Open_on_rhs"><a href="#module-Open_on_rhs" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Open_on_rhs/index.html">Open_on_rhs</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt/Let_syntax/index.html
Normal file
2
dev/lwt/Lwt/Let_syntax/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Let_syntax (lwt.Lwt.Let_syntax)</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">lwt</a> » <a href="../index.html">Lwt</a> » Let_syntax</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt.Let_syntax</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec module anchored" id="module-Let_syntax"><a href="#module-Let_syntax" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Let_syntax/index.html">Let_syntax</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt/Syntax/index.html
Normal file
2
dev/lwt/Lwt/Syntax/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Syntax (lwt.Lwt.Syntax)</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">lwt</a> » <a href="../index.html">Lwt</a> » Syntax</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt.Syntax</span></code></h1></header><nav class="odoc-toc"><ul><li><a href="#let-syntax">Let syntax</a></li><li><a href="#monadic-syntax">Monadic syntax</a></li><li><a href="#applicative-syntax">Applicative syntax</a></li></ul></nav><div class="odoc-content"><h4 id="let-syntax"><a href="#let-syntax" class="anchor"></a>Let syntax</h4><h2 id="monadic-syntax"><a href="#monadic-syntax" class="anchor"></a>Monadic syntax</h2><div class="odoc-spec"><div class="spec value anchored" id="val-let*"><a href="#val-let*" class="anchor"></a><code><span><span class="keyword">val</span> let* : <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Syntax for <a href="../index.html#val-bind"><code>bind</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-and*"><a href="#val-and*" class="anchor"></a><code><span><span class="keyword">val</span> and* : <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>)</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Syntax for <a href="../index.html#val-both"><code>both</code></a>.</p></div></div><h2 id="applicative-syntax"><a href="#applicative-syntax" class="anchor"></a>Applicative syntax</h2><div class="odoc-spec"><div class="spec value anchored" id="val-let+"><a href="#val-let+" class="anchor"></a><code><span><span class="keyword">val</span> let+ : <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Syntax for <a href="../index.html#val-map"><code>map</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-and+"><a href="#val-and+" class="anchor"></a><code><span><span class="keyword">val</span> and+ : <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>)</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Syntax for <a href="../index.html#val-both"><code>both</code></a>.</p></div></div></div></body></html>
|
||||
356
dev/lwt/Lwt/index.html
Normal file
356
dev/lwt/Lwt/index.html
Normal file
File diff suppressed because one or more lines are too long
42
dev/lwt/Lwt_bytes/index.html
Normal file
42
dev/lwt/Lwt_bytes/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_condition/index.html
Normal file
2
dev/lwt/Lwt_condition/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_condition (lwt.Lwt_condition)</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">lwt</a> » Lwt_condition</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_condition</span></code></h1><p>Conditions</p></header><div class="odoc-content"><p>Condition variables to synchronize between threads.</p><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>Condition variable type. The type parameter denotes the type of value propagated from notifier to waiter.</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>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> creates a new condition variable.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-wait"><a href="#val-wait" class="anchor"></a><code><span><span class="keyword">val</span> wait : <span><span class="optlabel">?mutex</span>:<a href="../Lwt_mutex/index.html#type-t">Lwt_mutex.t</a> <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="type-var">'a</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>wait mutex condvar</code> will cause the current thread to block, awaiting notification for a condition variable, <code>condvar</code>. If provided, the <code>mutex</code> must have been previously locked (within the scope of <code>Lwt_mutex.with_lock</code>, for example) and is temporarily unlocked until the condition is notified. Upon notification, <code>mutex</code> is re-locked before <code>wait</code> returns and the thread's activity is resumed. When the awaited condition is notified, the value parameter passed to <code>signal</code> is returned.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-signal"><a href="#val-signal" class="anchor"></a><code><span><span class="keyword">val</span> signal : <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>signal condvar value</code> notifies that a condition is ready. A single waiting thread will be awoken and will receive the notification value which will be returned from <code>wait</code>. Note that condition notification is not "sticky", i.e. if there is no waiter when <code>signal</code> is called, the notification will be missed and the value discarded.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-broadcast"><a href="#val-broadcast" class="anchor"></a><code><span><span class="keyword">val</span> broadcast : <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>broadcast condvar value</code> notifies all waiting threads. Each will be awoken in turn and will receive the same notification value.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-broadcast_exn"><a href="#val-broadcast_exn" class="anchor"></a><code><span><span class="keyword">val</span> broadcast_exn : <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>broadcast_exn condvar exn</code> fails all waiting threads with exception <code>exn</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.6.0</li></ul></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_config/index.html
Normal file
2
dev/lwt/Lwt_config/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_engine/Ev_backend/index.html
Normal file
2
dev/lwt/Lwt_engine/Ev_backend/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Ev_backend (lwt.Lwt_engine.Ev_backend)</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">lwt</a> » <a href="../index.html">Lwt_engine</a> » Ev_backend</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_engine.Ev_backend</span></code></h1></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-default"><a href="#val-default" class="anchor"></a><code><span><span class="keyword">val</span> default : <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-select"><a href="#val-select" class="anchor"></a><code><span><span class="keyword">val</span> select : <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-poll"><a href="#val-poll" class="anchor"></a><code><span><span class="keyword">val</span> poll : <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-epoll"><a href="#val-epoll" class="anchor"></a><code><span><span class="keyword">val</span> epoll : <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-kqueue"><a href="#val-kqueue" class="anchor"></a><code><span><span class="keyword">val</span> kqueue : <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-devpoll"><a href="#val-devpoll" class="anchor"></a><code><span><span class="keyword">val</span> devpoll : <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-port"><a href="#val-port" class="anchor"></a><code><span><span class="keyword">val</span> port : <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-pp"><a href="#val-pp" class="anchor"></a><code><span><span class="keyword">val</span> pp : <span><a href="../../../ocaml/Stdlib/Format/index.html#type-formatter">Stdlib.Format.formatter</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_engine/Versioned/class-libev_1/index.html
Normal file
2
dev/lwt/Lwt_engine/Versioned/class-libev_1/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>libev_1 (lwt.Lwt_engine.Versioned.libev_1)</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">lwt</a> » <a href="../../index.html">Lwt_engine</a> » <a href="../index.html">Versioned</a> » libev_1</nav><header class="odoc-preamble"><h1>Class <code><span>Versioned.libev_1</span></code></h1><p>Old version of <a href="../../class-libev/index.html"><code>Lwt_engine.libev</code></a>. The current <a href="../../class-libev/index.html"><code>Lwt_engine.libev</code></a> allows selecting the libev back end.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../../class-libev/index.html"><code>Lwt_engine.libev</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.7.0</li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../../class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value instance-variable anchored" id="val-loop"><a href="#val-loop" class="anchor"></a><code><span><span class="keyword">val</span> loop : <a href="../../index.html#type-ev_loop">ev_loop</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-loop"><a href="#method-loop" class="anchor"></a><code><span><span class="keyword">method</span> loop : <a href="../../index.html#type-ev_loop">ev_loop</a></span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_engine/Versioned/class-libev_2/index.html
Normal file
2
dev/lwt/Lwt_engine/Versioned/class-libev_2/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>libev_2 (lwt.Lwt_engine.Versioned.libev_2)</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">lwt</a> » <a href="../../index.html">Lwt_engine</a> » <a href="../index.html">Versioned</a> » libev_2</nav><header class="odoc-preamble"><h1>Class <code><span>Versioned.libev_2</span></code></h1><p>Since Lwt 3.0.0, this is just an alias for <a href="../../class-libev/index.html"><code>Lwt_engine.libev</code></a>.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../../class-libev/index.html"><code>Lwt_engine.libev</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.7.0</li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../../class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value instance-variable anchored" id="val-loop"><a href="#val-loop" class="anchor"></a><code><span><span class="keyword">val</span> loop : <a href="../../index.html#type-ev_loop">ev_loop</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-loop"><a href="#method-loop" class="anchor"></a><code><span><span class="keyword">method</span> loop : <a href="../../index.html#type-ev_loop">ev_loop</a></span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_engine/Versioned/index.html
Normal file
2
dev/lwt/Lwt_engine/Versioned/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Versioned (lwt.Lwt_engine.Versioned)</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">lwt</a> » <a href="../index.html">Lwt_engine</a> » Versioned</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_engine.Versioned</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec class anchored" id="class-libev_1"><a href="#class-libev_1" class="anchor"></a><code><span><span class="keyword">class</span> </span><span><a href="class-libev_1/index.html">libev_1</a></span><span> : <span class="keyword">object</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>Old version of <a href="../class-libev/index.html"><code>Lwt_engine.libev</code></a>. The current <a href="../class-libev/index.html"><code>Lwt_engine.libev</code></a> allows selecting the libev back end.</p></div></div><div class="odoc-spec"><div class="spec class anchored" id="class-libev_2"><a href="#class-libev_2" class="anchor"></a><code><span><span class="keyword">class</span> </span><span><a href="class-libev_2/index.html">libev_2</a></span><span> : <span><span class="optlabel">?backend</span>:<a href="../Ev_backend/index.html#type-t">Ev_backend.t</a> <span class="arrow">-></span></span> <span>unit <span class="arrow">-></span></span> <span class="keyword">object</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>Since Lwt 3.0.0, this is just an alias for <a href="../class-libev/index.html"><code>Lwt_engine.libev</code></a>.</p></div></div></div></body></html>
|
||||
9
dev/lwt/Lwt_engine/class-abstract/index.html
Normal file
9
dev/lwt/Lwt_engine/class-abstract/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_engine/class-libev/index.html
Normal file
2
dev/lwt/Lwt_engine/class-libev/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>libev (lwt.Lwt_engine.libev)</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">lwt</a> » <a href="../index.html">Lwt_engine</a> » libev</nav><header class="odoc-preamble"><h1>Class <code><span>Lwt_engine.libev</span></code></h1><p>Engine based on libev. If not compiled with libev support, the creation of the class will raise <a href="../../Lwt_sys/index.html#exception-Not_available"><code>Lwt_sys.Not_available</code></a>.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value instance-variable anchored" id="val-loop"><a href="#val-loop" class="anchor"></a><code><span><span class="keyword">val</span> loop : <a href="../index.html#type-ev_loop">ev_loop</a></span></code></div><div class="spec-doc"><p>The libev loop used for this engine.</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-loop"><a href="#method-loop" class="anchor"></a><code><span><span class="keyword">method</span> loop : <a href="../index.html#type-ev_loop">ev_loop</a></span></code></div><div class="spec-doc"><p>Returns <code>loop</code>.</p></div></div></div></body></html>
|
||||
4
dev/lwt/Lwt_engine/class-poll_based/index.html
Normal file
4
dev/lwt/Lwt_engine/class-poll_based/index.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>poll_based (lwt.Lwt_engine.poll_based)</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">lwt</a> » <a href="../index.html">Lwt_engine</a> » poll_based</nav><header class="odoc-preamble"><h1>Class <code><span>Lwt_engine.poll_based</span></code></h1><p>Abstract class for engines based on a poll-like function.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-poll"><a href="#method-poll" class="anchor"></a><code><span><span class="keyword">method</span> <span class="keyword">private</span> <span class="keyword">virtual</span> poll : <span><span><span>(<a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> * bool * bool)</span> list</span> <span class="arrow">-></span></span>
|
||||
<span>float <span class="arrow">-></span></span>
|
||||
<span><span>(<a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> * bool * bool)</span> list</span></span></code></div><div class="spec-doc"><p><code>poll fds tiomeout</code>, where <code>fds</code> is a list of tuples of the form <code>(fd, check_readable, check_writable)</code>, waits for either:</p><ul><li>one of the file descriptor with <code>check_readable</code> set to <code>true</code> to become readable</li><li>one of the file descriptor with <code>check_writable</code> set to <code>true</code> to become writable</li><li>timeout to expire</li></ul><p>and returns the list of file descriptors with their readable and writable status.</p></div></div></div></body></html>
|
||||
6
dev/lwt/Lwt_engine/class-select/index.html
Normal file
6
dev/lwt/Lwt_engine/class-select/index.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>select (lwt.Lwt_engine.select)</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">lwt</a> » <a href="../index.html">Lwt_engine</a> » select</nav><header class="odoc-preamble"><h1>Class <code><span>Lwt_engine.select</span></code></h1><p>Engine based on <a href="../../../ocaml/Unix/index.html#val-select"><code>Unix.select</code></a>.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../class-abstract/index.html">abstract</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-iter"><a href="#method-iter" class="anchor"></a><code><span><span class="keyword">method</span> iter : <span>bool <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-cleanup"><a href="#method-cleanup" class="anchor"></a><code><span><span class="keyword">method</span> <span class="keyword">private</span> cleanup : unit</span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-register_readable"><a href="#method-register_readable" class="anchor"></a><code><span><span class="keyword">method</span> <span class="keyword">private</span> register_readable : <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span>
|
||||
<span><span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span>unit <a href="../../../ocaml/Stdlib/Lazy/index.html#type-t">Lazy.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-register_writable"><a href="#method-register_writable" class="anchor"></a><code><span><span class="keyword">method</span> <span class="keyword">private</span> register_writable : <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span>
|
||||
<span><span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span>unit <a href="../../../ocaml/Stdlib/Lazy/index.html#type-t">Lazy.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-register_timer"><a href="#method-register_timer" class="anchor"></a><code><span><span class="keyword">method</span> <span class="keyword">private</span> register_timer : <span>float <span class="arrow">-></span></span> <span>bool <span class="arrow">-></span></span> <span><span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span> <span>unit <a href="../../../ocaml/Stdlib/Lazy/index.html#type-t">Lazy.t</a></span></span></code></div></div></div></body></html>
|
||||
5
dev/lwt/Lwt_engine/class-select_based/index.html
Normal file
5
dev/lwt/Lwt_engine/class-select_based/index.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>select_based (lwt.Lwt_engine.select_based)</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">lwt</a> » <a href="../index.html">Lwt_engine</a> » select_based</nav><header class="odoc-preamble"><h1>Class <code><span>Lwt_engine.select_based</span></code></h1><p>Abstract class for engines based on a select-like function.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-select"><a href="#method-select" class="anchor"></a><code><span><span class="keyword">method</span> <span class="keyword">private</span> <span class="keyword">virtual</span> select : <span><span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> list</span> <span class="arrow">-></span></span>
|
||||
<span><span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> list</span> <span class="arrow">-></span></span>
|
||||
<span>float <span class="arrow">-></span></span>
|
||||
<span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> list</span> * <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> list</span></span></code></div><div class="spec-doc"><p><code>select fds_r fds_w timeout</code> waits for either:</p><ul><li>one of the file descriptor of <code>fds_r</code> to become readable</li><li>one of the file descriptor of <code>fds_w</code> to become writable</li><li>timeout to expire</li></ul><p>and returns the list of readable file descriptor and the list of writable file descriptors.</p></div></div></div></body></html>
|
||||
6
dev/lwt/Lwt_engine/class-type-t/index.html
Normal file
6
dev/lwt/Lwt_engine/class-type-t/index.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>t (lwt.Lwt_engine.t)</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">lwt</a> » <a href="../index.html">Lwt_engine</a> » t</nav><header class="odoc-preamble"><h1>Class type <code><span>Lwt_engine.t</span></code></h1><p>Type of engines.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../class-abstract/index.html">abstract</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-iter"><a href="#method-iter" class="anchor"></a><code><span><span class="keyword">method</span> iter : <span>bool <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-cleanup"><a href="#method-cleanup" class="anchor"></a><code><span><span class="keyword">method</span> <span class="keyword">private</span> cleanup : unit</span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-register_readable"><a href="#method-register_readable" class="anchor"></a><code><span><span class="keyword">method</span> <span class="keyword">private</span> register_readable : <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span>
|
||||
<span><span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span>unit <a href="../../../ocaml/Stdlib/Lazy/index.html#type-t">Lazy.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-register_writable"><a href="#method-register_writable" class="anchor"></a><code><span><span class="keyword">method</span> <span class="keyword">private</span> register_writable : <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span>
|
||||
<span><span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span>unit <a href="../../../ocaml/Stdlib/Lazy/index.html#type-t">Lazy.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-register_timer"><a href="#method-register_timer" class="anchor"></a><code><span><span class="keyword">method</span> <span class="keyword">private</span> register_timer : <span>float <span class="arrow">-></span></span> <span>bool <span class="arrow">-></span></span> <span><span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span> <span>unit <a href="../../../ocaml/Stdlib/Lazy/index.html#type-t">Lazy.t</a></span></span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_engine/index.html
Normal file
2
dev/lwt/Lwt_engine/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_features/index.html
Normal file
2
dev/lwt/Lwt_features/index.html
Normal file
File diff suppressed because one or more lines are too long
20
dev/lwt/Lwt_fmt/index.html
Normal file
20
dev/lwt/Lwt_fmt/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_gc/index.html
Normal file
2
dev/lwt/Lwt_gc/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_gc (lwt.Lwt_gc)</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">lwt</a> » Lwt_gc</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_gc</span></code></h1><p>Interaction with the garbage collector</p></header><div class="odoc-content"><p>This module offers a convenient way to add a finaliser launching a thread to a value, without having to use <code>Lwt_unix.run</code> in the finaliser.</p><div class="odoc-spec"><div class="spec value anchored" id="val-finalise"><a href="#val-finalise" class="anchor"></a><code><span><span class="keyword">val</span> finalise : <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</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>finalise f x</code> ensures <code>f x</code> is evaluated after <code>x</code> has been garbage collected. If <code>f x</code> yields, then Lwt will wait for its termination at the end of the program.</p><p>Note that <code>f x</code> is not called at garbage collection time, but later in the main loop.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-finalise_or_exit"><a href="#val-finalise_or_exit" class="anchor"></a><code><span><span class="keyword">val</span> finalise_or_exit : <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</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>finalise_or_exit f x</code> call <code>f x</code> when <code>x</code> is garbage collected or (exclusively) when the program exits.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_io/BE/index.html
Normal file
2
dev/lwt/Lwt_io/BE/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_io/LE/index.html
Normal file
2
dev/lwt/Lwt_io/LE/index.html
Normal file
File diff suppressed because one or more lines are too long
15
dev/lwt/Lwt_io/Versioned/index.html
Normal file
15
dev/lwt/Lwt_io/Versioned/index.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Versioned (lwt.Lwt_io.Versioned)</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">lwt</a> » <a href="../index.html">Lwt_io</a> » Versioned</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_io.Versioned</span></code></h1><p>Versioned variants of APIs undergoing breaking changes.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-establish_server_1"><a href="#val-establish_server_1" class="anchor"></a><code><span><span class="keyword">val</span> establish_server_1 :
|
||||
<span><span class="optlabel">?fd</span>:<a href="../../Lwt_unix/index.html#type-file_descr">Lwt_unix.file_descr</a> <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?buffer_size</span>:int <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?backlog</span>:int <span class="arrow">-></span></span>
|
||||
<span><a href="../../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a> <span class="arrow">-></span></span>
|
||||
<span><span>(<span><span>(<a href="../index.html#type-input_channel">input_channel</a> * <a href="../index.html#type-output_channel">output_channel</a>)</span> <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<a href="../index.html#type-server">server</a></span></code></div><div class="spec-doc"><p>Old version of <a href="../index.html#val-establish_server"><code>Lwt_io.establish_server</code></a>. The current <a href="../index.html#val-establish_server"><code>Lwt_io.establish_server</code></a> automatically closes channels passed to the callback, and notifies the caller when the server's listening socket is bound.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../index.html#val-establish_server_with_client_address"><code>Lwt_io.establish_server_with_client_address</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.7.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-establish_server_2"><a href="#val-establish_server_2" class="anchor"></a><code><span><span class="keyword">val</span> establish_server_2 :
|
||||
<span><span class="optlabel">?fd</span>:<a href="../../Lwt_unix/index.html#type-file_descr">Lwt_unix.file_descr</a> <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?buffer_size</span>:int <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?backlog</span>:int <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?no_close</span>:bool <span class="arrow">-></span></span>
|
||||
<span><a href="../../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a> <span class="arrow">-></span></span>
|
||||
<span><span>(<span><span>(<a href="../index.html#type-input_channel">input_channel</a> * <a href="../index.html#type-output_channel">output_channel</a>)</span> <span class="arrow">-></span></span> <span>unit <a href="../../Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">-></span></span>
|
||||
<span><a href="../index.html#type-server">server</a> <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Since Lwt 3.0.0, this is just an alias for <a href="../index.html#val-establish_server"><code>Lwt_io.establish_server</code></a>.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../index.html#val-establish_server_with_client_address"><code>Lwt_io.establish_server_with_client_address</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.7.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-shutdown_server_1"><a href="#val-shutdown_server_1" class="anchor"></a><code><span><span class="keyword">val</span> shutdown_server_1 : <span><a href="../index.html#type-server">server</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Old version of <a href="../index.html#val-shutdown_server"><code>Lwt_io.shutdown_server</code></a>. The current <a href="../index.html#val-shutdown_server"><code>Lwt_io.shutdown_server</code></a> returns a promise, which resolves when the server's listening socket is closed.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../index.html#val-shutdown_server"><code>Lwt_io.shutdown_server</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.7.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-shutdown_server_2"><a href="#val-shutdown_server_2" class="anchor"></a><code><span><span class="keyword">val</span> shutdown_server_2 : <span><a href="../index.html#type-server">server</a> <span class="arrow">-></span></span> <span>unit <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Since Lwt 3.0.0, this is just an alias for <a href="../index.html#val-shutdown_server"><code>Lwt_io.shutdown_server</code></a>.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../index.html#val-shutdown_server"><code>Lwt_io.shutdown_server</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.7.0</li></ul></div></div></div></body></html>
|
||||
125
dev/lwt/Lwt_io/index.html
Normal file
125
dev/lwt/Lwt_io/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_io/module-type-NumberIO/index.html
Normal file
2
dev/lwt/Lwt_io/module-type-NumberIO/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_list/index.html
Normal file
2
dev/lwt/Lwt_list/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_main/Enter_iter_hooks/index.html
Normal file
2
dev/lwt/Lwt_main/Enter_iter_hooks/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Enter_iter_hooks (lwt.Lwt_main.Enter_iter_hooks)</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">lwt</a> » <a href="../index.html">Lwt_main</a> » Enter_iter_hooks</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_main.Enter_iter_hooks</span></code></h1><p>Hooks, of type <code>unit -> unit</code>, that are called before each iteration of the Lwt main loop.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.2.0</li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-kind"><a href="#type-kind" class="anchor"></a><code><span><span class="keyword">type</span> <span>'return_value kind</span></span><span> = <span class="type-var">'return_value</span></span></code></div><div class="spec-doc"><p>Hooks are functions of either type <code>unit -> unit</code> or <code>unit -> unit Lwt.t</code>; this type constructor is used only to express both possibilities in one signature.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-hook"><a href="#type-hook" class="anchor"></a><code><span><span class="keyword">type</span> hook</span></code></div><div class="spec-doc"><p>Values of type <code>hook</code> represent hooks that have been added, so that they can be removed later (if needed).</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_first"><a href="#val-add_first" class="anchor"></a><code><span><span class="keyword">val</span> add_first : <span><span>(<span>unit <span class="arrow">-></span></span> <span>unit <a href="#type-kind">kind</a></span>)</span> <span class="arrow">-></span></span> <a href="#type-hook">hook</a></span></code></div><div class="spec-doc"><p>Adds a hook to the hook sequence underlying this module, to be run <em>first</em>, before any other hooks already added.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_last"><a href="#val-add_last" class="anchor"></a><code><span><span class="keyword">val</span> add_last : <span><span>(<span>unit <span class="arrow">-></span></span> <span>unit <a href="#type-kind">kind</a></span>)</span> <span class="arrow">-></span></span> <a href="#type-hook">hook</a></span></code></div><div class="spec-doc"><p>Adds a hook to the hook sequence underlying this module, to be run <em>last</em>, after any other hooks already added.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove"><a href="#val-remove" class="anchor"></a><code><span><span class="keyword">val</span> remove : <span><a href="#type-hook">hook</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Removes a hook added by <a href="#val-add_first"><code>add_first</code></a> or <a href="#val-add_last"><code>add_last</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove_all"><a href="#val-remove_all" class="anchor"></a><code><span><span class="keyword">val</span> remove_all : <span>unit <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Removes all hooks from the hook sequence underlying this module.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_main/Exit_hooks/index.html
Normal file
2
dev/lwt/Lwt_main/Exit_hooks/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Exit_hooks (lwt.Lwt_main.Exit_hooks)</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">lwt</a> » <a href="../index.html">Lwt_main</a> » Exit_hooks</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_main.Exit_hooks</span></code></h1><p>Promise-returning hooks, of type <code>unit -> unit Lwt.t</code>, that are called at process exit. Exceptions raised by these hooks are ignored.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.2.0</li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-kind"><a href="#type-kind" class="anchor"></a><code><span><span class="keyword">type</span> <span>'return_value kind</span></span><span> = <span><span class="type-var">'return_value</span> <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Hooks are functions of either type <code>unit -> unit</code> or <code>unit -> unit Lwt.t</code>; this type constructor is used only to express both possibilities in one signature.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-hook"><a href="#type-hook" class="anchor"></a><code><span><span class="keyword">type</span> hook</span></code></div><div class="spec-doc"><p>Values of type <code>hook</code> represent hooks that have been added, so that they can be removed later (if needed).</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_first"><a href="#val-add_first" class="anchor"></a><code><span><span class="keyword">val</span> add_first : <span><span>(<span>unit <span class="arrow">-></span></span> <span>unit <a href="#type-kind">kind</a></span>)</span> <span class="arrow">-></span></span> <a href="#type-hook">hook</a></span></code></div><div class="spec-doc"><p>Adds a hook to the hook sequence underlying this module, to be run <em>first</em>, before any other hooks already added.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_last"><a href="#val-add_last" class="anchor"></a><code><span><span class="keyword">val</span> add_last : <span><span>(<span>unit <span class="arrow">-></span></span> <span>unit <a href="#type-kind">kind</a></span>)</span> <span class="arrow">-></span></span> <a href="#type-hook">hook</a></span></code></div><div class="spec-doc"><p>Adds a hook to the hook sequence underlying this module, to be run <em>last</em>, after any other hooks already added.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove"><a href="#val-remove" class="anchor"></a><code><span><span class="keyword">val</span> remove : <span><a href="#type-hook">hook</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Removes a hook added by <a href="#val-add_first"><code>add_first</code></a> or <a href="#val-add_last"><code>add_last</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove_all"><a href="#val-remove_all" class="anchor"></a><code><span><span class="keyword">val</span> remove_all : <span>unit <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Removes all hooks from the hook sequence underlying this module.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_main/Leave_iter_hooks/index.html
Normal file
2
dev/lwt/Lwt_main/Leave_iter_hooks/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Leave_iter_hooks (lwt.Lwt_main.Leave_iter_hooks)</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">lwt</a> » <a href="../index.html">Lwt_main</a> » Leave_iter_hooks</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_main.Leave_iter_hooks</span></code></h1><p>Hooks, of type <code>unit -> unit</code>, that are called after each iteration of the Lwt main loop.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.2.0</li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-kind"><a href="#type-kind" class="anchor"></a><code><span><span class="keyword">type</span> <span>'return_value kind</span></span><span> = <span class="type-var">'return_value</span></span></code></div><div class="spec-doc"><p>Hooks are functions of either type <code>unit -> unit</code> or <code>unit -> unit Lwt.t</code>; this type constructor is used only to express both possibilities in one signature.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-hook"><a href="#type-hook" class="anchor"></a><code><span><span class="keyword">type</span> hook</span></code></div><div class="spec-doc"><p>Values of type <code>hook</code> represent hooks that have been added, so that they can be removed later (if needed).</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_first"><a href="#val-add_first" class="anchor"></a><code><span><span class="keyword">val</span> add_first : <span><span>(<span>unit <span class="arrow">-></span></span> <span>unit <a href="#type-kind">kind</a></span>)</span> <span class="arrow">-></span></span> <a href="#type-hook">hook</a></span></code></div><div class="spec-doc"><p>Adds a hook to the hook sequence underlying this module, to be run <em>first</em>, before any other hooks already added.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_last"><a href="#val-add_last" class="anchor"></a><code><span><span class="keyword">val</span> add_last : <span><span>(<span>unit <span class="arrow">-></span></span> <span>unit <a href="#type-kind">kind</a></span>)</span> <span class="arrow">-></span></span> <a href="#type-hook">hook</a></span></code></div><div class="spec-doc"><p>Adds a hook to the hook sequence underlying this module, to be run <em>last</em>, after any other hooks already added.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove"><a href="#val-remove" class="anchor"></a><code><span><span class="keyword">val</span> remove : <span><a href="#type-hook">hook</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Removes a hook added by <a href="#val-add_first"><code>add_first</code></a> or <a href="#val-add_last"><code>add_last</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove_all"><a href="#val-remove_all" class="anchor"></a><code><span><span class="keyword">val</span> remove_all : <span>unit <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Removes all hooks from the hook sequence underlying this module.</p></div></div></div></body></html>
|
||||
4
dev/lwt/Lwt_main/index.html
Normal file
4
dev/lwt/Lwt_main/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_main/module-type-Hooks/index.html
Normal file
2
dev/lwt/Lwt_main/module-type-Hooks/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Hooks (lwt.Lwt_main.Hooks)</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">lwt</a> » <a href="../index.html">Lwt_main</a> » Hooks</nav><header class="odoc-preamble"><h1>Module type <code><span>Lwt_main.Hooks</span></code></h1><p>Hook sequences. Each module of this type is a set of hooks, to be run by Lwt at certain points during execution. See modules <a href="../Enter_iter_hooks/index.html"><code>Enter_iter_hooks</code></a>, <a href="../Leave_iter_hooks/index.html"><code>Leave_iter_hooks</code></a>, and <a href="../Exit_hooks/index.html"><code>Exit_hooks</code></a>.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-kind"><a href="#type-kind" class="anchor"></a><code><span><span class="keyword">type</span> <span>'return_value kind</span></span></code></div><div class="spec-doc"><p>Hooks are functions of either type <code>unit -> unit</code> or <code>unit -> unit Lwt.t</code>; this type constructor is used only to express both possibilities in one signature.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-hook"><a href="#type-hook" class="anchor"></a><code><span><span class="keyword">type</span> hook</span></code></div><div class="spec-doc"><p>Values of type <code>hook</code> represent hooks that have been added, so that they can be removed later (if needed).</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_first"><a href="#val-add_first" class="anchor"></a><code><span><span class="keyword">val</span> add_first : <span><span>(<span>unit <span class="arrow">-></span></span> <span>unit <a href="#type-kind">kind</a></span>)</span> <span class="arrow">-></span></span> <a href="#type-hook">hook</a></span></code></div><div class="spec-doc"><p>Adds a hook to the hook sequence underlying this module, to be run <em>first</em>, before any other hooks already added.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_last"><a href="#val-add_last" class="anchor"></a><code><span><span class="keyword">val</span> add_last : <span><span>(<span>unit <span class="arrow">-></span></span> <span>unit <a href="#type-kind">kind</a></span>)</span> <span class="arrow">-></span></span> <a href="#type-hook">hook</a></span></code></div><div class="spec-doc"><p>Adds a hook to the hook sequence underlying this module, to be run <em>last</em>, after any other hooks already added.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove"><a href="#val-remove" class="anchor"></a><code><span><span class="keyword">val</span> remove : <span><a href="#type-hook">hook</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Removes a hook added by <a href="#val-add_first"><code>add_first</code></a> or <a href="#val-add_last"><code>add_last</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove_all"><a href="#val-remove_all" class="anchor"></a><code><span><span class="keyword">val</span> remove_all : <span>unit <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Removes all hooks from the hook sequence underlying this module.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_mutex/index.html
Normal file
2
dev/lwt/Lwt_mutex/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_mutex (lwt.Lwt_mutex)</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">lwt</a> » Lwt_mutex</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_mutex</span></code></h1><p>Cooperative locks for mutual exclusion</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 class="spec-doc"><p>Type of Lwt mutexes</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>unit <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>create ()</code> creates a new mutex, which is initially unlocked</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-lock"><a href="#val-lock" class="anchor"></a><code><span><span class="keyword">val</span> lock : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>lock mutex</code> lockcs the mutex, that is:</p><ul><li>if the mutex is unlocked, then it is marked as locked and <a href="#val-lock"><code>lock</code></a> returns immediately</li></ul><ul><li>if it is locked, then <a href="#val-lock"><code>lock</code></a> waits for all threads waiting on the mutex to terminate, then it resumes when the last one unlocks the mutex</li></ul><p>Note: threads are woken up in the same order they try to lock the mutex</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-unlock"><a href="#val-unlock" class="anchor"></a><code><span><span class="keyword">val</span> unlock : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>unlock mutex</code> unlock the mutex if no threads is waiting on it. Otherwise it will eventually removes the first one and resumes it.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_locked"><a href="#val-is_locked" class="anchor"></a><code><span><span class="keyword">val</span> is_locked : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p><code>locked mutex</code> returns whether <code>mutex</code> is currently locked</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_empty"><a href="#val-is_empty" class="anchor"></a><code><span><span class="keyword">val</span> is_empty : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p><code>is_empty mutex</code> returns <code>true</code> if they are no thread waiting on the mutex, and <code>false</code> otherwise</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-with_lock"><a href="#val-with_lock" class="anchor"></a><code><span><span class="keyword">val</span> with_lock : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><span>(<span>unit <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>with_lock lock f</code> is used to lock a mutex within a block scope. The function <code>f ()</code> is called with the mutex locked, and its result is returned from the call to <code>with_lock</code>. If an exception is raised from f, the mutex is also unlocked before the scope of <code>with_lock</code> is exited.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_mvar/index.html
Normal file
2
dev/lwt/Lwt_mvar/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_mvar (lwt.Lwt_mvar)</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">lwt</a> » Lwt_mvar</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_mvar</span></code></h1><p>Mailbox variables</p></header><div class="odoc-content"><p>“Mailbox” variables implement a synchronising variable, used for communication between concurrent threads.</p><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>The type of a mailbox variable. Mailbox variables are used to communicate values between threads in a synchronous way. The type parameter specifies the type of the value propagated from <code>put</code> to <code>take</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="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>create v</code> creates a new mailbox variable containing value <code>v</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-create_empty"><a href="#val-create_empty" class="anchor"></a><code><span><span class="keyword">val</span> create_empty : <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> creates a new empty mailbox variable.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-put"><a href="#val-put" class="anchor"></a><code><span><span class="keyword">val</span> put : <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> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>put mvar value</code> puts a value into a mailbox variable. This value will remain in the mailbox until <code>take</code> is called to remove it. If the mailbox is not empty, the current thread will block until it is emptied.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-take"><a href="#val-take" class="anchor"></a><code><span><span class="keyword">val</span> take : <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="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>take mvar</code> will take any currently available value from the mailbox variable. If no value is currently available, the current thread will block, awaiting a value to be <code>put</code> by another thread.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-take_available"><a href="#val-take_available" class="anchor"></a><code><span><span class="keyword">val</span> take_available : <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> option</span></span></code></div><div class="spec-doc"><p><code>take_available mvar</code> immediately takes the value from <code>mvar</code> without blocking, returning <code>None</code> if the mailbox is empty.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.2.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_empty"><a href="#val-is_empty" class="anchor"></a><code><span><span class="keyword">val</span> is_empty : <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_empty mvar</code> indicates if <code>put mvar</code> can be called without blocking.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.2.0</li></ul></div></div></div></body></html>
|
||||
22
dev/lwt/Lwt_pool/index.html
Normal file
22
dev/lwt/Lwt_pool/index.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_pool (lwt.Lwt_pool)</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">lwt</a> » Lwt_pool</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_pool</span></code></h1><p>External resource pools.</p><p>This module provides an abstraction for managing collections of resources. One example use case is for managing a pool of database connections, where instead of establishing a new connection each time you need one (which is expensive), you can keep a pool of opened connections and reuse ones that are free.</p><p>It also provides the capability of:</p><ul><li>specifying the maximum number of resources that the pool can manage simultaneously,</li><li>checking whether a resource is still valid before/after use, and</li><li>performing cleanup logic before dropping a resource.</li></ul><p>The following example illustrates how it is used with an imaginary <code>Db</code> module:</p><pre class="language-ocaml"><code>let uri = "postgresql://localhost:5432"
|
||||
|
||||
(* Create a database connection pool with max size of 10. *)
|
||||
let pool =
|
||||
Lwt_pool.create 10
|
||||
~dispose:(fun connection -> Db.close connection |> Lwt.return)
|
||||
(fun () -> Db.connect uri |> Lwt.return)
|
||||
|
||||
(* Use the pool in queries. *)
|
||||
let create_user name =
|
||||
Lwt_pool.use pool (fun connection ->
|
||||
connection
|
||||
|> Db.insert "users" [("name", name)]
|
||||
|> Lwt.return
|
||||
)</code></pre><p>Note that this is <em>not</em> intended to keep a pool of system threads. If you want to have such pool, consider using <a href="../Lwt_preemptive/index.html"><code>Lwt_preemptive</code></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>A pool containing elements 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>int <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?validate</span>:<span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span>bool <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?check</span>:<span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span>(<span>bool <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?dispose</span>:<span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">-></span></span>
|
||||
<span><span>(<span>unit <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</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>create n ?check ?validate ?dispose f</code> creates a new pool with at most <code>n</code> elements. <code>f</code> is used to create a new pool element. Elements are created on demand and re-used until disposed of.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">validate</span> <p>is called each time a pool element is accessed by <a href="#val-use"><code>use</code></a>, before the element is provided to <a href="#val-use"><code>use</code></a>'s callback. If <code>validate element</code> resolves to <code>true</code> the element is considered valid and is passed to the callback for use as-is. If <code>validate element</code> resolves to <code>false</code> the tested pool element is passed to <code>dispose</code> then dropped, with a new one is created to take <code>element</code>'s place in the pool. <code>validate</code> is available since Lwt 3.2.0.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">check</span> <p>is called after the resolution of <a href="#val-use"><code>use</code></a>'s callback when the resolution is a failed promise. <code>check element is_ok</code> must call <code>is_ok</code> exactly once with <code>true</code> if <code>element</code> is still valid and <code>false</code> otherwise. If <code>check</code> calls <code>is_ok false</code> then <code>dispose</code> will be run on <code>element</code> and the element will not be returned to the pool.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">dispose</span> <p>is used as described above and by <a href="#val-clear"><code>clear</code></a> to dispose of all elements in a pool. <code>dispose</code> is <b>not</b> guaranteed to be called on the elements in a pool when the pool is garbage collected. <a href="#val-clear"><code>clear</code></a> should be used if the elements of the pool need to be explicitly disposed of.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-use"><a href="#val-use" class="anchor"></a><code><span><span class="keyword">val</span> use : <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>use p f</code> requests one free element of the pool <code>p</code> and gives it to the function <code>f</code>. The element is put back into the pool after the promise created by <code>f</code> completes.</p><p>In the case that <code>p</code> is exhausted and the maximum number of elements is reached, <code>use</code> will wait until one becomes free.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-clear"><a href="#val-clear" class="anchor"></a><code><span><span class="keyword">val</span> clear : <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">-></span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>clear p</code> will clear all elements in <code>p</code>, calling the <code>dispose</code> function associated with <code>p</code> on each of the cleared elements. Any elements from <code>p</code> which are currently in use will be disposed of once they are released.</p><p>The next call to <code>use p</code> after <code>clear p</code> guarantees a freshly created pool element.</p><p>Disposals are performed sequentially in an undefined order.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.2.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-wait_queue_length"><a href="#val-wait_queue_length" class="anchor"></a><code><span><span class="keyword">val</span> wait_queue_length : <span><span><span class="type-var">_</span> <a href="#type-t">t</a></span> <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p><code>wait_queue_length p</code> returns the number of <a href="#val-use"><code>use</code></a> requests currently waiting for an element of the pool <code>p</code> to become available.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.2.0</li></ul></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_pqueue/Make/argument-1-Ord/index.html
Normal file
2
dev/lwt/Lwt_pqueue/Make/argument-1-Ord/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Ord (lwt.Lwt_pqueue.Make.Ord)</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">lwt</a> » <a href="../../index.html">Lwt_pqueue</a> » <a href="../index.html">Make</a> » Ord</nav><header class="odoc-preamble"><h1>Parameter <code><span>Make.Ord</span></code></h1></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-compare"><a href="#val-compare" class="anchor"></a><code><span><span class="keyword">val</span> compare : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> int</span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_pqueue/Make/index.html
Normal file
2
dev/lwt/Lwt_pqueue/Make/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_pqueue/index.html
Normal file
2
dev/lwt/Lwt_pqueue/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_pqueue (lwt.Lwt_pqueue)</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">lwt</a> » Lwt_pqueue</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_pqueue</span></code></h1><p>Functional priority queues (deprecated).</p><p>A priority queue maintains, in the abstract sense, a set of elements in order, and supports fast lookup and removal of the first (“minimum”) element. This is used in Lwt for organizing threads that are waiting for timeouts.</p><p>The priority queues in this module preserve “duplicates”: elements that compare equal in their order.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>This module is an internal implementation detail of Lwt, and may be removed from the API at some point in the future. For alternatives, see, for example: <a href="https://www.lri.fr/~filliatr/software.en.html#heap">Heaps</a> by Jean-Cristophe Filliatre, <a href="http://cedeela.fr/~simon/software/containers/CCHeap.html">containers</a>, <a href="http://ocaml-batteries-team.github.io/batteries-included/hdoc2/BatHeap.html">Batteries</a>, or <a href="https://github.com/pqwy/psq">psq</a>.</p></li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec module-type anchored" id="module-type-OrderedType"><a href="#module-type-OrderedType" class="anchor"></a><code><span><span class="keyword">module</span> <span class="keyword">type</span> <a href="module-type-OrderedType/index.html">OrderedType</a></span><span> = <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>Signature pairing an element type with an ordering function.</p></div></div><div class="odoc-spec"><div class="spec module-type anchored" id="module-type-S"><a href="#module-type-S" class="anchor"></a><code><span><span class="keyword">module</span> <span class="keyword">type</span> <a href="module-type-S/index.html">S</a></span><span> = <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>Signature of priority queues.</p></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Make"><a href="#module-Make" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Make/index.html">Make</a></span><span> (<a href="Make/argument-1-Ord/index.html">Ord</a> : <a href="module-type-OrderedType/index.html">OrderedType</a>) : <a href="module-type-S/index.html">S</a> <span class="keyword">with</span> <span><span class="keyword">type</span> <a href="module-type-S/index.html#type-elt">elt</a> = <a href="Make/argument-1-Ord/index.html#type-t">Ord.t</a></span></span></code></div><div class="spec-doc"><p>Generates priority queue types from ordered types.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_pqueue/module-type-OrderedType/index.html
Normal file
2
dev/lwt/Lwt_pqueue/module-type-OrderedType/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>OrderedType (lwt.Lwt_pqueue.OrderedType)</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">lwt</a> » <a href="../index.html">Lwt_pqueue</a> » OrderedType</nav><header class="odoc-preamble"><h1>Module type <code><span>Lwt_pqueue.OrderedType</span></code></h1><p>Signature pairing an element type with an ordering function.</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-compare"><a href="#val-compare" class="anchor"></a><code><span><span class="keyword">val</span> compare : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> int</span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_pqueue/module-type-S/index.html
Normal file
2
dev/lwt/Lwt_pqueue/module-type-S/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>S (lwt.Lwt_pqueue.S)</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">lwt</a> » <a href="../index.html">Lwt_pqueue</a> » S</nav><header class="odoc-preamble"><h1>Module type <code><span>Lwt_pqueue.S</span></code></h1><p>Signature of priority queues.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-elt"><a href="#type-elt" class="anchor"></a><code><span><span class="keyword">type</span> elt</span></code></div><div class="spec-doc"><p>Type of elements contained in the priority queue.</p></div></div><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 class="spec-doc"><p>Type of priority queues.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-empty"><a href="#val-empty" class="anchor"></a><code><span><span class="keyword">val</span> empty : <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>The empty priority queue. Contains no elements.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_empty"><a href="#val-is_empty" class="anchor"></a><code><span><span class="keyword">val</span> is_empty : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p><code>is_empty q</code> evaluates to <code>true</code> iff <code>q</code> is empty.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add"><a href="#val-add" class="anchor"></a><code><span><span class="keyword">val</span> add : <span><a href="#type-elt">elt</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>add e q</code> evaluates to a new priority queue, which contains all the elements of <code>q</code>, and the additional element <code>e</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-union"><a href="#val-union" class="anchor"></a><code><span><span class="keyword">val</span> union : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>union q q'</code> evaluates to a new priority queue, which contains all the elements of both <code>q</code> and <code>q'</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-find_min"><a href="#val-find_min" class="anchor"></a><code><span><span class="keyword">val</span> find_min : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="#type-elt">elt</a></span></code></div><div class="spec-doc"><p><code>find_min q</code> evaluates to the minimum element of <code>q</code> if it is not empty, and raises <code>Not_found</code> otherwise.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-lookup_min"><a href="#val-lookup_min" class="anchor"></a><code><span><span class="keyword">val</span> lookup_min : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-elt">elt</a> option</span></span></code></div><div class="spec-doc"><p><code>lookup_min q</code> evaluates to <code>Some e</code>, where <code>e</code> is the minimum element of <code>q</code>, if <code>q</code> is not empty, and evaluates to <code>None</code> otherwise.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove_min"><a href="#val-remove_min" class="anchor"></a><code><span><span class="keyword">val</span> remove_min : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>remove_min q</code> evaluates to a new priority queue, which contains all the elements of <code>q</code> except for its minimum element. Raises <code>Not_found</code> if <code>q</code> is empty.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-size"><a href="#val-size" class="anchor"></a><code><span><span class="keyword">val</span> size : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p><code>size q</code> evaluates to the number of elements in <code>q</code>.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_preemptive/index.html
Normal file
2
dev/lwt/Lwt_preemptive/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_process/class-process/index.html
Normal file
2
dev/lwt/Lwt_process/class-process/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>process (lwt.Lwt_process.process)</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">lwt</a> » <a href="../index.html">Lwt_process</a> » process</nav><header class="odoc-preamble"><h1>Class <code><span>Lwt_process.process</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../class-process_none/index.html">process_none</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-stdin"><a href="#method-stdin" class="anchor"></a><code><span><span class="keyword">method</span> stdin : <a href="../../Lwt_io/index.html#type-output_channel">Lwt_io.output_channel</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-stdout"><a href="#method-stdout" class="anchor"></a><code><span><span class="keyword">method</span> stdout : <a href="../../Lwt_io/index.html#type-input_channel">Lwt_io.input_channel</a></span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_process/class-process_full/index.html
Normal file
2
dev/lwt/Lwt_process/class-process_full/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>process_full (lwt.Lwt_process.process_full)</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">lwt</a> » <a href="../index.html">Lwt_process</a> » process_full</nav><header class="odoc-preamble"><h1>Class <code><span>Lwt_process.process_full</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../class-process_none/index.html">process_none</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-stdin"><a href="#method-stdin" class="anchor"></a><code><span><span class="keyword">method</span> stdin : <a href="../../Lwt_io/index.html#type-output_channel">Lwt_io.output_channel</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-stdout"><a href="#method-stdout" class="anchor"></a><code><span><span class="keyword">method</span> stdout : <a href="../../Lwt_io/index.html#type-input_channel">Lwt_io.input_channel</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-stderr"><a href="#method-stderr" class="anchor"></a><code><span><span class="keyword">method</span> stderr : <a href="../../Lwt_io/index.html#type-input_channel">Lwt_io.input_channel</a></span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_process/class-process_in/index.html
Normal file
2
dev/lwt/Lwt_process/class-process_in/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>process_in (lwt.Lwt_process.process_in)</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">lwt</a> » <a href="../index.html">Lwt_process</a> » process_in</nav><header class="odoc-preamble"><h1>Class <code><span>Lwt_process.process_in</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../class-process_none/index.html">process_none</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-stdout"><a href="#method-stdout" class="anchor"></a><code><span><span class="keyword">method</span> stdout : <a href="../../Lwt_io/index.html#type-input_channel">Lwt_io.input_channel</a></span></code></div><div class="spec-doc"><p>The standard output of the process</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_process/class-process_none/index.html
Normal file
2
dev/lwt/Lwt_process/class-process_none/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>process_none (lwt.Lwt_process.process_none)</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">lwt</a> » <a href="../index.html">Lwt_process</a> » process_none</nav><header class="odoc-preamble"><h1>Class <code><span>Lwt_process.process_none</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec method anchored" id="method-pid"><a href="#method-pid" class="anchor"></a><code><span><span class="keyword">method</span> pid : int</span></code></div><div class="spec-doc"><p>Pid of the sub-process</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-state"><a href="#method-state" class="anchor"></a><code><span><span class="keyword">method</span> state : <a href="../index.html#type-state">state</a></span></code></div><div class="spec-doc"><p>Return the state of the process</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-kill"><a href="#method-kill" class="anchor"></a><code><span><span class="keyword">method</span> kill : <span>int <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>kill signum</code> sends <code>signum</code> to the process if it is still running.</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-terminate"><a href="#method-terminate" class="anchor"></a><code><span><span class="keyword">method</span> terminate : unit</span></code></div><div class="spec-doc"><p>Terminates the process. It is equivalent to <code>kill Sys.sigkill</code> on Unix but also works on Windows (unlike <code>Lwt_process.process_none.kill</code>).</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-status"><a href="#method-status" class="anchor"></a><code><span><span class="keyword">method</span> status : <span><a href="../../../ocaml/Unix/index.html#type-process_status">Unix.process_status</a> <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Threads which wait for the sub-process to exit then returns its exit status</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-rusage"><a href="#method-rusage" class="anchor"></a><code><span><span class="keyword">method</span> rusage : <span><a href="../../Lwt_unix/index.html#type-resource_usage">Lwt_unix.resource_usage</a> <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Threads which wait for the sub-process to exit then returns its resource usages</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-close"><a href="#method-close" class="anchor"></a><code><span><span class="keyword">method</span> close : <span><a href="../../../ocaml/Unix/index.html#type-process_status">Unix.process_status</a> <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Closes the process and returns its exit status. This closes all channels used to communicate with the process</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_process/class-process_out/index.html
Normal file
2
dev/lwt/Lwt_process/class-process_out/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>process_out (lwt.Lwt_process.process_out)</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">lwt</a> » <a href="../index.html">Lwt_process</a> » process_out</nav><header class="odoc-preamble"><h1>Class <code><span>Lwt_process.process_out</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec inherit"><code><span><span class="keyword">inherit</span> <a href="../class-process_none/index.html">process_none</a></span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-stdin"><a href="#method-stdin" class="anchor"></a><code><span><span class="keyword">method</span> stdin : <a href="../../Lwt_io/index.html#type-output_channel">Lwt_io.output_channel</a></span></code></div><div class="spec-doc"><p>The standard input of the process</p></div></div></div></body></html>
|
||||
173
dev/lwt/Lwt_process/index.html
Normal file
173
dev/lwt/Lwt_process/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_result/Infix/index.html
Normal file
2
dev/lwt/Lwt_result/Infix/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Infix (lwt.Lwt_result.Infix)</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">lwt</a> » <a href="../index.html">Lwt_result</a> » Infix</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_result.Infix</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-(>|=)"><a href="#val-(>|=)" class="anchor"></a><code><span><span class="keyword">val</span> (>|=) : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(>>=)"><a href="#val-(>>=)" class="anchor"></a><code><span><span class="keyword">val</span> (>>=) : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span>)</span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span></span></code></div></div></div></body></html>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Open_on_rhs (lwt.Lwt_result.Let_syntax.Let_syntax.Open_on_rhs)</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">lwt</a> » <a href="../../../index.html">Lwt_result</a> » <a href="../../index.html">Let_syntax</a> » <a href="../index.html">Let_syntax</a> » Open_on_rhs</nav><header class="odoc-preamble"><h1>Module <code><span>Let_syntax.Open_on_rhs</span></code></h1></header><div class="odoc-content"></div></body></html>
|
||||
2
dev/lwt/Lwt_result/Let_syntax/Let_syntax/index.html
Normal file
2
dev/lwt/Lwt_result/Let_syntax/Let_syntax/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Let_syntax (lwt.Lwt_result.Let_syntax.Let_syntax)</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">lwt</a> » <a href="../../index.html">Lwt_result</a> » <a href="../index.html">Let_syntax</a> » Let_syntax</nav><header class="odoc-preamble"><h1>Module <code><span>Let_syntax.Let_syntax</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-return"><a href="#val-return" class="anchor"></a><code><span><span class="keyword">val</span> return : <span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'a</span>, <span class="type-var">_</span>)</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-return"><code>Lwt_result.return</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-map"><a href="#val-map" class="anchor"></a><code><span><span class="keyword">val</span> map : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'e</span>)</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="label">f</span>:<span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-map"><code>Lwt_result.map</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bind"><a href="#val-bind" class="anchor"></a><code><span><span class="keyword">val</span> bind : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'e</span>)</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="label">f</span>:<span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../../index.html#type-t">t</a></span>)</span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-bind"><code>Lwt_result.bind</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-both"><a href="#val-both" class="anchor"></a><code><span><span class="keyword">val</span> both : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'e</span>)</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>See <a href="../../index.html#val-both"><code>Lwt_result.both</code></a>.</p></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Open_on_rhs"><a href="#module-Open_on_rhs" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Open_on_rhs/index.html">Open_on_rhs</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_result/Let_syntax/index.html
Normal file
2
dev/lwt/Lwt_result/Let_syntax/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Let_syntax (lwt.Lwt_result.Let_syntax)</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">lwt</a> » <a href="../index.html">Lwt_result</a> » Let_syntax</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_result.Let_syntax</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec module anchored" id="module-Let_syntax"><a href="#module-Let_syntax" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Let_syntax/index.html">Let_syntax</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_result/Syntax/index.html
Normal file
2
dev/lwt/Lwt_result/Syntax/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Syntax (lwt.Lwt_result.Syntax)</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">lwt</a> » <a href="../index.html">Lwt_result</a> » Syntax</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_result.Syntax</span></code></h1></header><nav class="odoc-toc"><ul><li><a href="#let-syntax">Let syntax</a></li><li><a href="#monadic-syntax">Monadic syntax</a></li><li><a href="#applicative-syntax">Applicative syntax</a></li></ul></nav><div class="odoc-content"><h4 id="let-syntax"><a href="#let-syntax" class="anchor"></a>Let syntax</h4><h2 id="monadic-syntax"><a href="#monadic-syntax" class="anchor"></a>Monadic syntax</h2><div class="odoc-spec"><div class="spec value anchored" id="val-let*"><a href="#val-let*" class="anchor"></a><code><span><span class="keyword">val</span> let* : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span>)</span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Syntax for <a href="../index.html#val-bind"><code>bind</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-and*"><a href="#val-and*" class="anchor"></a><code><span><span class="keyword">val</span> and* : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Syntax for <a href="../index.html#val-both"><code>both</code></a>.</p></div></div><h2 id="applicative-syntax"><a href="#applicative-syntax" class="anchor"></a>Applicative syntax</h2><div class="odoc-spec"><div class="spec value anchored" id="val-let+"><a href="#val-let+" class="anchor"></a><code><span><span class="keyword">val</span> let+ : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Syntax for <a href="../index.html#val-map"><code>map</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-and+"><a href="#val-and+" class="anchor"></a><code><span><span class="keyword">val</span> and+ : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span><span>(<span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>, <span class="type-var">'e</span>)</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Syntax for <a href="../index.html#val-both"><code>both</code></a>.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_result/index.html
Normal file
2
dev/lwt/Lwt_result/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_seq/index.html
Normal file
2
dev/lwt/Lwt_seq/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_sequence/index.html
Normal file
2
dev/lwt/Lwt_sequence/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_stream/class-type-bounded_push/index.html
Normal file
2
dev/lwt/Lwt_stream/class-type-bounded_push/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>bounded_push (lwt.Lwt_stream.bounded_push)</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">lwt</a> » <a href="../index.html">Lwt_stream</a> » bounded_push</nav><header class="odoc-preamble"><h1>Class type <code><span>Lwt_stream.bounded_push</span></code></h1><p>Type of sources for bounded push-streams.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec method anchored" id="method-size"><a href="#method-size" class="anchor"></a><code><span><span class="keyword">method</span> size : int</span></code></div><div class="spec-doc"><p>Size of the stream.</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-resize"><a href="#method-resize" class="anchor"></a><code><span><span class="keyword">method</span> resize : <span>int <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Change the size of the stream queue. Note that the new size can smaller than the current stream queue size.</p><p>It raises <code>Stdlib.Invalid_argument</code> if <code>size < 0</code>.</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-push"><a href="#method-push" class="anchor"></a><code><span><span class="keyword">method</span> push : <span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span>unit <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Pushes a new element to the stream. If the stream is full then it will block until one element is consumed. If another thread is already blocked on <code>push</code>, it raises <code>Lwt_stream.Full</code>.</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-close"><a href="#method-close" class="anchor"></a><code><span><span class="keyword">method</span> close : unit</span></code></div><div class="spec-doc"><p>Closes the stream. Any thread currently blocked on <code>Lwt_stream.bounded_push.push</code> fails with <code>Lwt_stream.Closed</code>.</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-count"><a href="#method-count" class="anchor"></a><code><span><span class="keyword">method</span> count : int</span></code></div><div class="spec-doc"><p>Number of elements in the stream queue.</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-blocked"><a href="#method-blocked" class="anchor"></a><code><span><span class="keyword">method</span> blocked : bool</span></code></div><div class="spec-doc"><p>Is a thread is blocked on <code>Lwt_stream.bounded_push.push</code> ?</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-closed"><a href="#method-closed" class="anchor"></a><code><span><span class="keyword">method</span> closed : bool</span></code></div><div class="spec-doc"><p>Is the stream closed ?</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-set_reference"><a href="#method-set_reference" class="anchor"></a><code><span><span class="keyword">method</span> set_reference : 'a. <span><span class="type-var">'a</span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Set the reference to an external source.</p></div></div></div></body></html>
|
||||
21
dev/lwt/Lwt_stream/index.html
Normal file
21
dev/lwt/Lwt_stream/index.html
Normal file
File diff suppressed because one or more lines are too long
16
dev/lwt/Lwt_switch/index.html
Normal file
16
dev/lwt/Lwt_switch/index.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_switch (lwt.Lwt_switch)</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">lwt</a> » Lwt_switch</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_switch</span></code></h1><p>Lwt switches</p></header><div class="odoc-content"><p>Switch has two goals:</p><ul><li>being able to free multiple resources at the same time,</li><li>offer a better alternative than always returning an id to free some resource.</li></ul><p>For example, consider the following interface:</p><pre class="language-ocaml"><code>type id
|
||||
|
||||
val free : id -> unit Lwt.t
|
||||
|
||||
val f : unit -> id Lwt.t
|
||||
val g : unit -> id Lwt.t
|
||||
val h : unit -> id Lwt.t</code></pre><p>Now you want to call <code>f</code>, <code>g</code> and <code>h</code> in parallel. You can simply do:</p><pre class="language-ocaml"><code>lwt idf = f () and idg = g () and idh = h () in
|
||||
...</code></pre><p>However, one may want to handle possible failures of <code>f ()</code>, <code>g ()</code> and <code>h ()</code>, and disable all allocated resources if one of these three threads fails. This may be hard since you have to remember which one failed and which one returned correctly.</p><p>Now if we change the interface a little bit:</p><pre class="language-ocaml"><code>val f : ?switch : Lwt_switch.t -> unit -> id Lwt.t
|
||||
val g : ?switch : Lwt_switch.t -> unit -> id Lwt.t
|
||||
val h : ?switch : Lwt_switch.t -> unit -> id Lwt.t</code></pre><p>the code becomes:</p><pre class="language-ocaml"><code>Lwt_switch.with_switch (fun switch ->
|
||||
lwt idf = f ~switch ()
|
||||
and idg = g ~switch ()
|
||||
and idh = h ~switch () in
|
||||
...
|
||||
)</code></pre><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 class="spec-doc"><p>Type of switches.</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>unit <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>create ()</code> creates a new switch.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-with_switch"><a href="#val-with_switch" class="anchor"></a><code><span><span class="keyword">val</span> with_switch : <span><span>(<span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>with_switch fn</code> is <code>fn switch</code>, where <code>switch</code> is a fresh switch that is turned off when the callback thread finishes (whether it succeeds or fails).</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.6.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_on"><a href="#val-is_on" class="anchor"></a><code><span><span class="keyword">val</span> is_on : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p><code>is_on switch</code> returns <code>true</code> if the switch is currently on, and <code>false</code> otherwise.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-turn_off"><a href="#val-turn_off" class="anchor"></a><code><span><span class="keyword">val</span> turn_off : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>turn_off switch</code> turns off the switch. It calls all registered hooks, waits for all of them to terminate, then returns. If one of the hooks failed, it will fail with the exception raised by the hook. If the switch is already off, it does nothing.</p></div></div><div class="odoc-spec"><div class="spec exception anchored" id="exception-Off"><a href="#exception-Off" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Off</span></span></code></div><div class="spec-doc"><p>Exception raised when trying to add a hook to a switch that is already off.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-check"><a href="#val-check" class="anchor"></a><code><span><span class="keyword">val</span> check : <span><span><a href="#type-t">t</a> option</span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>check switch</code> does nothing if <code>switch</code> is <code>None</code> or contains an switch that is currently on, and raises <a href="#exception-Off"><code>Off</code></a> otherwise.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_hook"><a href="#val-add_hook" class="anchor"></a><code><span><span class="keyword">val</span> add_hook : <span><span><a href="#type-t">t</a> option</span> <span class="arrow">-></span></span> <span><span>(<span>unit <span class="arrow">-></span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>add_hook switch f</code> registers <code>f</code> so it will be called when <a href="#val-turn_off"><code>turn_off</code></a> is invoked. It does nothing if <code>switch</code> is <code>None</code>. If <code>switch</code> contains an switch that is already off then <a href="#exception-Off"><code>Off</code></a> is raised.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_hook_or_exec"><a href="#val-add_hook_or_exec" class="anchor"></a><code><span><span class="keyword">val</span> add_hook_or_exec : <span><span><a href="#type-t">t</a> option</span> <span class="arrow">-></span></span> <span><span>(<span>unit <span class="arrow">-></span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">-></span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>add_hook_or_exec switch f</code> is the same as <a href="#val-add_hook"><code>add_hook</code></a> except that if the switch is already off, <code>f</code> is called immediately.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_sys/index.html
Normal file
2
dev/lwt/Lwt_sys/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/lwt/Lwt_throttle/Make/argument-1-H/index.html
Normal file
2
dev/lwt/Lwt_throttle/Make/argument-1-H/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>H (lwt.Lwt_throttle.Make.H)</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">lwt</a> » <a href="../../index.html">Lwt_throttle</a> » <a href="../index.html">Make</a> » H</nav><header class="odoc-preamble"><h1>Parameter <code><span>Make.H</span></code></h1></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 class="spec-doc"><p>The type of the hashtable keys.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-equal"><a href="#val-equal" class="anchor"></a><code><span><span class="keyword">val</span> equal : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p>The equality predicate used to compare keys.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-hash"><a href="#val-hash" class="anchor"></a><code><span><span class="keyword">val</span> hash : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p>A hashing function on keys. It must be such that if two keys are equal according to <code>equal</code>, then they have identical hash values as computed by <code>hash</code>. Examples: suitable (<code>equal</code>, <code>hash</code>) pairs for arbitrary key types include</p><ul><li>(<code>(=)</code>, <a href="#val-hash"><code>hash</code></a>) for comparing objects by structure (provided objects do not contain floats)</li><li>(<code>(fun x y -> compare x y = 0)</code>, <a href="#val-hash"><code>hash</code></a>) for comparing objects by structure and handling <a href="../../../../ocaml/Stdlib/index.html#val-nan"><code>Stdlib.nan</code></a> correctly</li><li>(<code>(==)</code>, <a href="#val-hash"><code>hash</code></a>) for comparing objects by physical equality (e.g. for mutable or cyclic objects).</li></ul></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_throttle/Make/index.html
Normal file
2
dev/lwt/Lwt_throttle/Make/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Make (lwt.Lwt_throttle.Make)</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">lwt</a> » <a href="../index.html">Lwt_throttle</a> » Make</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_throttle.Make</span></code></h1></header><nav class="odoc-toc"><ul><li><a href="#parameters">Parameters</a></li><li><a href="#signature">Signature</a></li></ul></nav><div class="odoc-content"><h2 id="parameters"><a href="#parameters" class="anchor"></a>Parameters</h2><div class="odoc-spec"><div class="spec parameter anchored" id="argument-1-H"><a href="#argument-1-H" class="anchor"></a><code><span><span class="keyword">module</span> </span><span><a href="argument-1-H/index.html">H</a></span><span> : <a href="../../../ocaml/Stdlib/Hashtbl/module-type-HashedType/index.html">Stdlib.Hashtbl.HashedType</a></span></code></div></div><h2 id="signature"><a href="#signature" class="anchor"></a>Signature</h2><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> key</span><span> = <a href="argument-1-H/index.html#type-t">H.t</a></span></code></div></div><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">rate</span>:int <span class="arrow">-></span></span> <span><span class="label">max</span>:int <span class="arrow">-></span></span> <span><span class="label">n</span>:int <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Creates a rate limiter.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">rate</span> <p>Maximum number of promise resolutions per second, per channel.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">max</span> <p>Maximum number of pending promises allowed at once, over all channels.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">n</span> <p>Initial size of the internal channel hash table. This should be approximately the number of different channels that will be used.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-wait"><a href="#val-wait" class="anchor"></a><code><span><span class="keyword">val</span> wait : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-key">key</a> <span class="arrow">-></span></span> <span>bool <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>Lwt_throttle.wait limiter channel</code> returns a new promise associated with the given rate limiter and channel.</p><p>If the maximum number of pending promises for <code>limiter</code> has <em>not</em> been reached, the promise starts pending. It will be resolved with <code>true</code> at some future time, such that the rate limit of <code>limiter</code> is not exceeded, with respect to other promises in the same <code>channel</code>.</p><p>If the maximum number of pending promises has been reached, the returned promise is already resolved with <code>false</code>.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_throttle/index.html
Normal file
2
dev/lwt/Lwt_throttle/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_throttle (lwt.Lwt_throttle)</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">lwt</a> » Lwt_throttle</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_throttle</span></code></h1><p>Rate limiters.</p><p>A rate limiter allows generating sets of promises that will be resolved in the future, at a maximum rate of N promises per second.</p><p>The rate limiters in this module support multiple <em>channels</em>, each given a different key by the user. The rate limit applies to each channel independently.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec module-type anchored" id="module-type-S"><a href="#module-type-S" class="anchor"></a><code><span><span class="keyword">module</span> <span class="keyword">type</span> <a href="module-type-S/index.html">S</a></span><span> = <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Make"><a href="#module-Make" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Make/index.html">Make</a></span><span> (<a href="Make/argument-1-H/index.html">H</a> : <a href="../../ocaml/Stdlib/Hashtbl/module-type-HashedType/index.html">Stdlib.Hashtbl.HashedType</a>) : <a href="module-type-S/index.html">S</a> <span class="keyword">with</span> <span><span class="keyword">type</span> <a href="module-type-S/index.html#type-key">key</a> = <a href="Make/argument-1-H/index.html#type-t">H.t</a></span></span></code></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_throttle/module-type-S/index.html
Normal file
2
dev/lwt/Lwt_throttle/module-type-S/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>S (lwt.Lwt_throttle.S)</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">lwt</a> » <a href="../index.html">Lwt_throttle</a> » S</nav><header class="odoc-preamble"><h1>Module type <code><span>Lwt_throttle.S</span></code></h1></header><div class="odoc-content"><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> key</span></code></div></div><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">rate</span>:int <span class="arrow">-></span></span> <span><span class="label">max</span>:int <span class="arrow">-></span></span> <span><span class="label">n</span>:int <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Creates a rate limiter.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">rate</span> <p>Maximum number of promise resolutions per second, per channel.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">max</span> <p>Maximum number of pending promises allowed at once, over all channels.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">n</span> <p>Initial size of the internal channel hash table. This should be approximately the number of different channels that will be used.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-wait"><a href="#val-wait" class="anchor"></a><code><span><span class="keyword">val</span> wait : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-key">key</a> <span class="arrow">-></span></span> <span>bool <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>Lwt_throttle.wait limiter channel</code> returns a new promise associated with the given rate limiter and channel.</p><p>If the maximum number of pending promises for <code>limiter</code> has <em>not</em> been reached, the promise starts pending. It will be resolved with <code>true</code> at some future time, such that the rate limit of <code>limiter</code> is not exceeded, with respect to other promises in the same <code>channel</code>.</p><p>If the maximum number of pending promises has been reached, the returned promise is already resolved with <code>false</code>.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_timeout/index.html
Normal file
2
dev/lwt/Lwt_timeout/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_timeout (lwt.Lwt_timeout)</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">lwt</a> » Lwt_timeout</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_timeout</span></code></h1><p>Cancelable timeouts.</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>int <span class="arrow">-></span></span> <span><span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>Lwt_timeout.create n f</code> creates a new timeout object with duration <code>n</code> seconds. <code>f</code> is the <em>action</em>, a function to be called once the timeout expires. <code>f</code> should not raise exceptions.</p><p>The timeout is not started until <a href="#val-start"><code>Lwt_timeout.start</code></a> is called on it.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-start"><a href="#val-start" class="anchor"></a><code><span><span class="keyword">val</span> start : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Starts the given timeout.</p><p>Starting a timeout that has already been started has the same effect as stopping it, and then restarting it with its original duration. So, suppose you have <code>timeout</code> with a duration of three seconds, which was started two seconds ago. The next call to its action is scheduled for one second in the future. Calling <code>Lwt_timeout.start timeout</code> at this point cancels this upcoming action call, and schedules a call three seconds from now.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-stop"><a href="#val-stop" class="anchor"></a><code><span><span class="keyword">val</span> stop : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Stops (cancels) the given timeout.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-change"><a href="#val-change" class="anchor"></a><code><span><span class="keyword">val</span> change : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Changes the duration of the given timeout.</p><p>If the timeout has already been started, it is stopped, and restarted with its new duration. This is similar to how <a href="#val-start"><code>Lwt_timeout.start</code></a> works on a timeout that has already been started.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-set_exn_handler"><a href="#val-set_exn_handler" class="anchor"></a><code><span><span class="keyword">val</span> set_exn_handler : <span><span>(<span>exn <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>Lwt_timeout.set_exn_handler f</code> sets the handler to be used for exceptions raised by timeout actions. Recall that actions are not allowed to raise exceptions. If they do raise an exception <code>exn</code> despite this, <code>f exn</code> is called.</p><p>The default behavior of <code>f exn</code>, set by <code>Lwt_timeout</code> on program startup, is to pass <code>exn</code> to <code>!</code><a href="../Lwt/index.html#val-async_exception_hook"><code>Lwt.async_exception_hook</code></a>. The default behavior of <em>that</em> is to terminate the process.</p></div></div></div></body></html>
|
||||
4
dev/lwt/Lwt_unix/IO_vectors/index.html
Normal file
4
dev/lwt/Lwt_unix/IO_vectors/index.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>IO_vectors (lwt.Lwt_unix.IO_vectors)</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">lwt</a> » <a href="../index.html">Lwt_unix</a> » IO_vectors</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_unix.IO_vectors</span></code></h1><p>Sequences of buffer slices for <a href="../index.html#val-writev"><code>writev</code></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> t</span></code></div><div class="spec-doc"><p>Mutable sequences of I/O vectors. An I/O vector describes a slice of a <code>bytes</code> or <code>Bigarray</code> buffer. Each I/O vector is a triple containing a reference to the buffer, an offset into the buffer where the slice begins, and the length of the slice.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-_bigarray"><a href="#type-_bigarray" class="anchor"></a><code><span><span class="keyword">type</span> _bigarray</span><span> =
|
||||
<span><span>(char, <a href="../../../ocaml/Stdlib/Bigarray/index.html#type-int8_unsigned_elt">Stdlib.Bigarray.int8_unsigned_elt</a>, <a href="../../../ocaml/Stdlib/Bigarray/index.html#type-c_layout">Stdlib.Bigarray.c_layout</a>)</span>
|
||||
<a href="../../../ocaml/Stdlib/Bigarray/Array1/index.html#type-t">Stdlib.Bigarray.Array1.t</a></span></span></code></div><div class="spec-doc"><p>Type abbreviation equivalent to <a href="../../Lwt_bytes/index.html#type-t"><code>Lwt_bytes.t</code></a>. Do not use this type name directly; use <a href="../../Lwt_bytes/index.html#type-t"><code>Lwt_bytes.t</code></a> instead.</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>unit <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Creates an empty I/O vector sequence.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-append_bytes"><a href="#val-append_bytes" class="anchor"></a><code><span><span class="keyword">val</span> append_bytes : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>append_bytes vs buffer offset length</code> appends a slice of the <code>bytes</code> buffer <code>buffer</code> beginning at <code>offset</code> and with length <code>length</code> to the I/O vector sequence <code>vs</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-append_bigarray"><a href="#val-append_bigarray" class="anchor"></a><code><span><span class="keyword">val</span> append_bigarray : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-_bigarray">_bigarray</a> <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>append_bigarray vs buffer offset length</code> appends a slice of the <code>Bigarray</code> buffer <code>buffer</code> beginning at <code>offset</code> and with length <code>length</code> to the I/O vector sequence <code>vs</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-drop"><a href="#val-drop" class="anchor"></a><code><span><span class="keyword">val</span> drop : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>drop vs n</code> adjusts the I/O vector sequence <code>vs</code> so that it no longer includes its first <code>n</code> bytes.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_empty"><a href="#val-is_empty" class="anchor"></a><code><span><span class="keyword">val</span> is_empty : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p><code>is_empty vs</code> is <code>true</code> if and only if <code>vs</code> has no I/O vectors, or all I/O vectors in <code>vs</code> have zero bytes.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-byte_count"><a href="#val-byte_count" class="anchor"></a><code><span><span class="keyword">val</span> byte_count : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p><code>byte_count vs</code> is the total number of bytes in <code>vs</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.2.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-system_limit"><a href="#val-system_limit" class="anchor"></a><code><span><span class="keyword">val</span> system_limit : <span>int option</span></span></code></div><div class="spec-doc"><p>Some systems limit the number of I/O vectors that can be passed in a single call to their <code>writev</code> or <code>readv</code> system calls. On those systems, if the limit is <code>n</code>, this value is equal to <code>Some n</code>. On systems without such a limit, the value is equal to <code>None</code>.</p><p>Unless you need atomic I/O operations, you can ignore this limit. The Lwt binding automatically respects it internally. See <a href="../index.html#val-writev"><code>Lwt_unix.writev</code></a>.</p><p>A typical limit is 1024 vectors.</p></div></div></div></body></html>
|
||||
2
dev/lwt/Lwt_unix/LargeFile/index.html
Normal file
2
dev/lwt/Lwt_unix/LargeFile/index.html
Normal file
File diff suppressed because one or more lines are too long
9
dev/lwt/Lwt_unix/Versioned/index.html
Normal file
9
dev/lwt/Lwt_unix/Versioned/index.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Versioned (lwt.Lwt_unix.Versioned)</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">lwt</a> » <a href="../index.html">Lwt_unix</a> » Versioned</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_unix.Versioned</span></code></h1><p>Versioned variants of APIs undergoing breaking changes.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-bind_1"><a href="#val-bind_1" class="anchor"></a><code><span><span class="keyword">val</span> bind_1 : <span><a href="../index.html#type-file_descr">file_descr</a> <span class="arrow">-></span></span> <span><a href="../index.html#type-sockaddr">sockaddr</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Old version of <a href="../index.html#val-bind"><code>Lwt_unix.bind</code></a>. The current <a href="../index.html#val-bind"><code>Lwt_unix.bind</code></a> evaluates to a promise, because the internal <code>bind(2)</code> system call can block if the given socket is a Unix domain socket.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../index.html#val-bind"><code>Lwt_unix.bind</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.7.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bind_2"><a href="#val-bind_2" class="anchor"></a><code><span><span class="keyword">val</span> bind_2 : <span><a href="../index.html#type-file_descr">file_descr</a> <span class="arrow">-></span></span> <span><a href="../index.html#type-sockaddr">sockaddr</a> <span class="arrow">-></span></span> <span>unit <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Since Lwt 3.0.0, this is just an alias for <a href="../index.html#val-bind"><code>Lwt_unix.bind</code></a>.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../index.html#val-bind"><code>Lwt_unix.bind</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.7.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-recv_msg_2"><a href="#val-recv_msg_2" class="anchor"></a><code><span><span class="keyword">val</span> recv_msg_2 :
|
||||
<span><span class="label">socket</span>:<a href="../index.html#type-file_descr">file_descr</a> <span class="arrow">-></span></span>
|
||||
<span><span class="label">io_vectors</span>:<a href="../IO_vectors/index.html#type-t">IO_vectors.t</a> <span class="arrow">-></span></span>
|
||||
<span><span>(int * <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> list</span>)</span> <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Since Lwt 5.0.0, this is an alias for <a href="../index.html#val-recv_msg"><code>Lwt_unix.recv_msg</code></a>.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../index.html#val-recv_msg"><code>Lwt_unix.recv_msg</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.3.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-send_msg_2"><a href="#val-send_msg_2" class="anchor"></a><code><span><span class="keyword">val</span> send_msg_2 :
|
||||
<span><span class="label">socket</span>:<a href="../index.html#type-file_descr">file_descr</a> <span class="arrow">-></span></span>
|
||||
<span><span class="label">io_vectors</span>:<a href="../IO_vectors/index.html#type-t">IO_vectors.t</a> <span class="arrow">-></span></span>
|
||||
<span><span class="label">fds</span>:<span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> list</span> <span class="arrow">-></span></span>
|
||||
<span>int <a href="../../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Since Lwt 5.0.0, this is an alias for <a href="../index.html#val-send_msg"><code>Lwt_unix.send_msg</code></a>.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../index.html#val-send_msg"><code>Lwt_unix.send_msg</code></a>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.3.0</li></ul></div></div></div></body></html>
|
||||
76
dev/lwt/Lwt_unix/index.html
Normal file
76
dev/lwt/Lwt_unix/index.html
Normal file
File diff suppressed because one or more lines are too long
1145
dev/lwt/_doc-dir/CHANGES
Normal file
1145
dev/lwt/_doc-dir/CHANGES
Normal file
File diff suppressed because it is too large
Load diff
19
dev/lwt/_doc-dir/LICENSE.md
Normal file
19
dev/lwt/_doc-dir/LICENSE.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 1999-2020, the Authors of Lwt (docs/AUTHORS)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
187
dev/lwt/_doc-dir/README.md
Normal file
187
dev/lwt/_doc-dir/README.md
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
# Lwt
|
||||
|
||||
[![version][version]][releases] [![GitHub Actions status][github-actions-img]][github-actions]
|
||||
|
||||
[version]: https://img.shields.io/github/release/ocsigen/lwt
|
||||
[releases]: https://github.com/ocsigen/lwt/releases
|
||||
[github-actions]: https://github.com/ocsigen/lwt/actions
|
||||
[github-actions-img]: https://github.com/ocsigen/lwt/actions/workflows/workflow.yml/badge.svg?branch=master
|
||||
[appveyor]: https://ci.appveyor.com/project/aantron/lwt/branch/master
|
||||
[appveyor-img]: https://img.shields.io/appveyor/ci/aantron/lwt/master.svg?label=appveyor
|
||||
|
||||
Lwt is a concurrent programming library for OCaml. It provides a single data
|
||||
type: the *promise*, which is a value that will become determined in the future.
|
||||
Creating a promise spawns a computation. When that computation is I/O, Lwt runs
|
||||
it in parallel with your OCaml code.
|
||||
|
||||
OCaml code, including creating and waiting on promises, is run in a single
|
||||
thread by default, so you don't have to worry about locking or preemption. You
|
||||
can detach code to be run in separate threads on an opt-in basis.
|
||||
|
||||
Here is a simplistic Lwt program which requests the Google front page, and fails
|
||||
if the request is not completed in five seconds:
|
||||
|
||||
```ocaml
|
||||
open Lwt.Syntax
|
||||
|
||||
let () =
|
||||
let request =
|
||||
let* addresses = Lwt_unix.getaddrinfo "google.com" "80" [] in
|
||||
let google = Lwt_unix.((List.hd addresses).ai_addr) in
|
||||
|
||||
Lwt_io.(with_connection google (fun (incoming, outgoing) ->
|
||||
let* () = write outgoing "GET / HTTP/1.1\r\n" in
|
||||
let* () = write outgoing "Connection: close\r\n\r\n" in
|
||||
let* response = read incoming in
|
||||
Lwt.return (Some response)))
|
||||
in
|
||||
|
||||
let timeout =
|
||||
let* () = Lwt_unix.sleep 5. in
|
||||
Lwt.return None
|
||||
in
|
||||
|
||||
match Lwt_main.run (Lwt.pick [request; timeout]) with
|
||||
| Some response -> print_string response
|
||||
| None -> prerr_endline "Request timed out"; exit 1
|
||||
|
||||
(* ocamlfind opt -package lwt.unix -linkpkg example.ml && ./a.out *)
|
||||
```
|
||||
|
||||
In the program, functions such as `Lwt_io.write` create promises. The
|
||||
`let* ... in` construct is used to wait for a promise to become determined; the
|
||||
code after `in` is scheduled to run in a "callback." `Lwt.pick` races promises
|
||||
against each other, and behaves as the first one to complete. `Lwt_main.run`
|
||||
forces the whole promise-computation network to be executed. All the visible
|
||||
OCaml code is run in a single thread, but Lwt internally uses a combination of
|
||||
worker threads and non-blocking file descriptors to resolve in parallel the
|
||||
promises that do I/O.
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
### Overview
|
||||
|
||||
Lwt compiles to native code on Linux, macOS, Windows, and other systems. It's
|
||||
also routinely compiled to JavaScript for the front end and Node by js_of_ocaml.
|
||||
|
||||
In Lwt,
|
||||
|
||||
- The [core library `Lwt`][core] provides promises...
|
||||
- ...and a few pure-OCaml helpers, such as promise-friendly [mutexes][mutex],
|
||||
[condition variables][cond], and [mvars][mvar].
|
||||
- There is a big Unix binding, [`Lwt_unix`][unix] that binds almost every Unix
|
||||
system call. A higher-level module [`Lwt_io`][io] provides nice I/O channels.
|
||||
- [`Lwt_process`][process] is for subprocess handling.
|
||||
- [`Lwt_preemptive`][preemptive] spawns system threads.
|
||||
- The [PPX syntax][ppx] allows using all of the above without going crazy!
|
||||
- There are also some other helpers, such as [`Lwt_react`][react] for reactive
|
||||
programming. See the table of contents on the linked manual pages!
|
||||
|
||||
[core]: https://ocsigen.org/lwt/latest/api/Lwt
|
||||
[cond]: https://ocsigen.org/lwt/latest/api/Lwt_condition
|
||||
[mutex]: https://ocsigen.org/lwt/latest/api/Lwt_mutex
|
||||
[mvar]: https://ocsigen.org/lwt/latest/api/Lwt_mvar
|
||||
[unix]: https://ocsigen.org/lwt/latest/api/Lwt_unix
|
||||
[io]: https://ocsigen.org/lwt/latest/api/Lwt_io
|
||||
[process]: https://ocsigen.org/lwt/latest/api/Lwt_process
|
||||
[preemptive]: https://ocsigen.org/lwt/latest/api/Lwt_preemptive
|
||||
[ppx]: https://ocsigen.org/lwt/latest/api/Ppx_lwt
|
||||
[react]: https://ocsigen.org/lwt/latest/api/Lwt_react
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
## Installing
|
||||
|
||||
1. Use your system package manager to install a development libev package.
|
||||
It is often called `libev-dev` or `libev-devel`.
|
||||
2. `opam install conf-libev lwt`
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
## Documentation
|
||||
|
||||
We are currently working on improving the Lwt documentation (drastically; we are
|
||||
rewriting the manual). In the meantime:
|
||||
|
||||
- The current manual can be found [here][manual].
|
||||
- Mirage has a nicely-written [Lwt tutorial][mirage-tutorial].
|
||||
- An example of a [simple server][counter-server] written in Lwt.
|
||||
- [Concurrent Programming with Lwt][rwo-lwt] is a nice source of Lwt examples.
|
||||
They are translations of code from the excellent Real World OCaml, but are
|
||||
just as useful if you are not reading the book.
|
||||
|
||||
*Note: much of the current manual refers to `'a Lwt.t` as "lightweight threads"
|
||||
or just "threads." This will be fixed in the new manual. `'a Lwt.t` is a
|
||||
promise, and has nothing to do with system or preemptive threads.*
|
||||
|
||||
[manual]: http://ocsigen.org/lwt/
|
||||
[rwo-lwt]: https://github.com/dkim/rwo-lwt#readme
|
||||
[mirage-tutorial]: https://mirage.io/docs/tutorial-lwt
|
||||
[counter-server]: http://www.baturin.org/code/lwt-counter-server/
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
## Contact
|
||||
|
||||
Open an [issue][issues], visit [Discord][discord] chat, ask on
|
||||
[discuss.ocaml.org][discourse], or on [Stack Overflow][so].
|
||||
|
||||
Release announcements are made in [/r/ocaml][reddit], and on
|
||||
[discuss.ocaml.org][discourse]. Watching the repo for "Releases only" is also an
|
||||
option.
|
||||
|
||||
[irc]: http://webchat.freenode.net/?channels=#ocaml
|
||||
[so]: http://stackoverflow.com/questions/ask?tags=ocaml,lwt,ocaml-lwt
|
||||
[announcements]: https://github.com/ocsigen/lwt/issues/309
|
||||
[reddit]: https://www.reddit.com/r/ocaml/
|
||||
[caml-list]: https://sympa.inria.fr/sympa/arc/caml-list
|
||||
[discourse]: https://discuss.ocaml.org/tag/lwt
|
||||
[issues]: https://github.com/ocsigen/lwt/issues/new
|
||||
[discord]: https://discordapp.com/invite/cCYQbqN
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
## Contributing
|
||||
|
||||
- [`CONTRIBUTING.md`][contributing-md] contains tips for working on the code,
|
||||
such as how to check the code out, how review works, etc. There is also a
|
||||
high-level outline of the code base.
|
||||
- [Ask](#contact) us anything, whether it's about working on Lwt, or any
|
||||
question at all about it :)
|
||||
- The [documentation](#documentation) always needs proofreading and fixes.
|
||||
- You are welcome to pick up any other [issue][issues-and-prs], review a PR, add
|
||||
your opinion, etc.
|
||||
- Any feedback is welcome, including how to make contributing easier!
|
||||
|
||||
[issues-and-prs]: https://github.com/ocsigen/lwt/issues?utf8=%E2%9C%93&q=is%3Aopen
|
||||
[all-issues]: https://github.com/ocsigen/lwt/issues
|
||||
[contributing-md]: https://github.com/ocsigen/lwt/blob/master/docs/CONTRIBUTING.md#readme
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
## Libraries to use with Lwt
|
||||
|
||||
- [alcotest](https://github.com/mirage/alcotest/) —
|
||||
unit testing
|
||||
- [angstrom](https://github.com/inhabitedtype/angstrom) —
|
||||
parser combinators
|
||||
- [cohttp](https://github.com/mirage/ocaml-cohttp) — HTTP client and server
|
||||
- [cstruct](https://github.com/mirage/ocaml-cstruct) —
|
||||
interop with C-like structures
|
||||
- [ezjsonm](https://github.com/mirage/ezjsonm) —
|
||||
JSON parsing and output
|
||||
- [faraday](https://github.com/inhabitedtype/faraday) —
|
||||
serialization combinators
|
||||
- [logs](https://github.com/dbuenzli/logs) —
|
||||
logging
|
||||
- [lwt-parallel](https://github.com/ivg/parallel) —
|
||||
distributed computing
|
||||
- [mwt](https://github.com/hcarty/mwt) — preemptive (system) thread pools
|
||||
- [opium](https://github.com/rgrinberg/opium) —
|
||||
web framework
|
||||
131
dev/lwt/_doc-dir/odoc-pages/index.mld
Normal file
131
dev/lwt/_doc-dir/odoc-pages/index.mld
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
{0 Lwt}
|
||||
|
||||
{1 Introduction}
|
||||
|
||||
Lwt is a concurrent programming library for OCaml. It provides a single data
|
||||
type: the {e promise}, which is a value that will become determined in the
|
||||
future. Creating a promise spawns a computation. When that computation is I/O,
|
||||
Lwt runs it in parallel with your OCaml code.
|
||||
|
||||
OCaml code, including creating and waiting on promises, is run in a single
|
||||
thread by default, so you don't have to worry about locking or preemption. You
|
||||
can detach code to be run in separate threads on an opt-in basis.
|
||||
|
||||
Here is a simplistic Lwt program which requests the Google front page, and fails
|
||||
if the request is not completed in five seconds:
|
||||
|
||||
{[
|
||||
open Lwt.Syntax
|
||||
|
||||
let () =
|
||||
let request =
|
||||
let* addresses = Lwt_unix.getaddrinfo "google.com" "80" [] in
|
||||
let google = Lwt_unix.((List.hd addresses).ai_addr) in
|
||||
|
||||
Lwt_io.(with_connection google (fun (incoming, outgoing) ->
|
||||
let* () = write outgoing "GET / HTTP/1.1\r\n" in
|
||||
let* () = write outgoing "Connection: close\r\n\r\n" in
|
||||
let* response = read incoming in
|
||||
Lwt.return (Some response)))
|
||||
in
|
||||
|
||||
let timeout =
|
||||
let* () = Lwt_unix.sleep 5. in
|
||||
Lwt.return None
|
||||
in
|
||||
|
||||
match Lwt_main.run (Lwt.pick [request; timeout]) with
|
||||
| Some response -> print_string response
|
||||
| None -> prerr_endline "Request timed out"; exit 1
|
||||
|
||||
(* ocamlfind opt -package lwt.unix -linkpkg example.ml && ./a.out *)
|
||||
]}
|
||||
|
||||
In the program, functions such as [Lwt_io.write] create promises. The
|
||||
[let%lwt ... in] construct is used to wait for a promise to become determined;
|
||||
the code after [in] is scheduled to run in a "callback." [Lwt.pick] races
|
||||
promises against each other, and behaves as the first one to complete.
|
||||
[Lwt_main.run] forces the whole promise-computation network to be executed. All
|
||||
the visible OCaml code is run in a single thread, but Lwt internally uses a
|
||||
combination of worker threads and non-blocking file descriptors to resolve in
|
||||
parallel the promises that do I/O.
|
||||
|
||||
|
||||
|
||||
{1 Tour}
|
||||
|
||||
Lwt compiles to native code on Linux, macOS, Windows, and other systems. It's
|
||||
also routinely compiled to JavaScript for the front end and Node by js_of_ocaml.
|
||||
|
||||
In Lwt,
|
||||
|
||||
- The core library {!Lwt} provides promises...
|
||||
- ...and a few pure-OCaml helpers, such as promise-friendly {{!Lwt_mutex}
|
||||
mutexes}, {{!Lwt_condition} condition variables}, and {{!Lwt_mvar} mvars}.
|
||||
- There is a big Unix binding, {!Lwt_unix}, that binds almost every Unix system
|
||||
call. A higher-level module {!Lwt_io} provides nice I/O channels.
|
||||
- {!Lwt_process} is for subprocess handling.
|
||||
- {!Lwt_preemptive} spawns system threads.
|
||||
|
||||
|
||||
|
||||
{1 Installing}
|
||||
|
||||
+ Use your system package manager to install a development libev package. It is
|
||||
often called [libev-dev] or [libev-devel].
|
||||
+ [opam install conf-libev lwt]
|
||||
|
||||
|
||||
|
||||
{1 Additional Docs}
|
||||
|
||||
- {{:http://ocsigen.org/lwt/} Online manual}.
|
||||
- {{:https://github.com/dkim/rwo-lwt#readme} Concurrent Programming with Lwt} is
|
||||
a nice source of Lwt examples. They are translations of code from Real World
|
||||
OCaml, but are just as useful if you are not reading the book.
|
||||
- {{:https://mirage.io/wiki/tutorial-lwt} Mirage Lwt tutorial}.
|
||||
- {{:http://www.baturin.org/code/lwt-counter-server/} Example server} written
|
||||
with Lwt.
|
||||
|
||||
|
||||
|
||||
{1 API: Library [lwt]}
|
||||
|
||||
This is the system-independent, pure-OCaml core of Lwt. To link with it, use
|
||||
[(libraries lwt)] in your [dune] file.
|
||||
|
||||
{!modules:
|
||||
Lwt
|
||||
Lwt_list
|
||||
Lwt_stream
|
||||
Lwt_result
|
||||
Lwt_mutex
|
||||
Lwt_condition
|
||||
Lwt_mvar
|
||||
Lwt_switch
|
||||
Lwt_pool
|
||||
}
|
||||
|
||||
|
||||
|
||||
{1 API: Library [lwt.unix]}
|
||||
|
||||
This is the system call and I/O library. Despite its name, it is implemented on
|
||||
both Unix-like systems and Windows, although not all functions are available on
|
||||
Windows. To link with this library, use [(libraries lwt.unix)] in your [dune]
|
||||
file.
|
||||
|
||||
{!modules:
|
||||
Lwt_unix
|
||||
Lwt_main
|
||||
Lwt_io
|
||||
Lwt_process
|
||||
Lwt_bytes
|
||||
Lwt_preemptive
|
||||
Lwt_fmt
|
||||
Lwt_throttle
|
||||
Lwt_timeout
|
||||
Lwt_engine
|
||||
Lwt_gc
|
||||
Lwt_sys
|
||||
}
|
||||
25
dev/lwt/index.html
Normal file
25
dev/lwt/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/moonpool-lwt/Moonpool_lwt/IO/index.html
Normal file
2
dev/moonpool-lwt/Moonpool_lwt/IO/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>IO (moonpool-lwt.Moonpool_lwt.IO)</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-lwt</a> » <a href="../index.html">Moonpool_lwt</a> » IO</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt.IO</span></code></h1><p>IO using the Lwt event loop.</p><p>These IO operations work on non-blocking file descriptors and rely on a <code>Lwt_engine</code> event loop being active (meaning, <code>Lwt_main.run</code> is currently running in some thread).</p><p>Calling these functions must be done from a moonpool runner. A function like <code>read</code> will first try to perform the IO action directly (here, call <a href="../../../ocaml/Unix/index.html#val-read"><code>Unix.read</code></a>); if the action fails because the FD is not ready, then <code>await_readable</code> is called: it suspends the fiber and subscribes it to Lwt to be awakened when the FD becomes ready.</p></header><div class="odoc-content"><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><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span> <span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p>Read from the file descriptor</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-await_readable"><a href="#val-await_readable" class="anchor"></a><code><span><span class="keyword">val</span> await_readable : <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Suspend the fiber until the FD is readable</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write_once"><a href="#val-write_once" class="anchor"></a><code><span><span class="keyword">val</span> write_once : <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span> <span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p>Perform one write into the file descriptor</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-await_writable"><a href="#val-await_writable" class="anchor"></a><code><span><span class="keyword">val</span> await_writable : <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Suspend the fiber until the FD is writable</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write"><a href="#val-write" class="anchor"></a><code><span><span class="keyword">val</span> write : <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span> <span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Loop around <a href="#val-write_once"><code>write_once</code></a> to write the entire slice.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-sleep_s"><a href="#val-sleep_s" class="anchor"></a><code><span><span class="keyword">val</span> sleep_s : <span>float <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Suspend the fiber for <code>n</code> seconds.</p></div></div></div></body></html>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>t (moonpool-lwt.Moonpool_lwt.IO_in.t)</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-lwt</a> » <a href="../../index.html">Moonpool_lwt</a> » <a href="../index.html">IO_in</a> » t</nav><header class="odoc-preamble"><h1>Class type <code><span>IO_in.t</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec method anchored" id="method-input"><a href="#method-input" class="anchor"></a><code><span><span class="keyword">method</span> input : <span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p>Read into the slice. Returns <code>0</code> only if the stream is closed.</p></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-close"><a href="#method-close" class="anchor"></a><code><span><span class="keyword">method</span> close : <span>unit <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Close the input. Must be idempotent.</p></div></div></div></body></html>
|
||||
6
dev/moonpool-lwt/Moonpool_lwt/IO_in/index.html
Normal file
6
dev/moonpool-lwt/Moonpool_lwt/IO_in/index.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>IO_in (moonpool-lwt.Moonpool_lwt.IO_in)</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-lwt</a> » <a href="../index.html">Moonpool_lwt</a> » IO_in</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt.IO_in</span></code></h1><p>Input channel</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec class-type anchored" id="class-type-t"><a href="#class-type-t" class="anchor"></a><code><span><span class="keyword">class</span> <span class="keyword">type</span> </span><span><a href="class-type-t/index.html">t</a></span><span> = <span class="keyword">object</span> ... <span class="keyword">end</span></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="optlabel">?close</span>:<span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span><span class="label">input</span>:<span>(<span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> int)</span> <span class="arrow">-></span></span>
|
||||
<span>unit <span class="arrow">-></span></span>
|
||||
<a href="class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-empty"><a href="#val-empty" class="anchor"></a><code><span><span class="keyword">val</span> empty : <a href="class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-of_bytes"><a href="#val-of_bytes" class="anchor"></a><code><span><span class="keyword">val</span> of_bytes : <span><span class="optlabel">?off</span>:int <span class="arrow">-></span></span> <span><span class="optlabel">?len</span>:int <span class="arrow">-></span></span> <span>bytes <span class="arrow">-></span></span> <a href="class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-of_string"><a href="#val-of_string" class="anchor"></a><code><span><span class="keyword">val</span> of_string : <span><span class="optlabel">?off</span>:int <span class="arrow">-></span></span> <span><span class="optlabel">?len</span>:int <span class="arrow">-></span></span> <span>string <span class="arrow">-></span></span> <a href="class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-input"><a href="#val-input" class="anchor"></a><code><span><span class="keyword">val</span> input : <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> <span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p>Read into the given slice.</p><ul class="at-tags"><li class="returns"><span class="at-tag">returns</span> <p>the number of bytes read, <code>0</code> means end of input.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-close"><a href="#val-close" class="anchor"></a><code><span><span class="keyword">val</span> close : <span><span>< close : <span>unit <span class="arrow">-></span></span> unit.. ></span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Close the channel.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-really_input"><a href="#val-really_input" class="anchor"></a><code><span><span class="keyword">val</span> really_input : <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> <span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-really_input_string"><a href="#val-really_input_string" class="anchor"></a><code><span><span class="keyword">val</span> really_input_string : <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> string</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-copy_into"><a href="#val-copy_into" class="anchor"></a><code><span><span class="keyword">val</span> copy_into : <span><span class="optlabel">?buf</span>:bytes <span class="arrow">-></span></span> <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> <span><a href="../IO_out/class-type-t/index.html">IO_out.t</a> <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-concat"><a href="#val-concat" class="anchor"></a><code><span><span class="keyword">val</span> concat : <span><span><a href="class-type-t/index.html">t</a> list</span> <span class="arrow">-></span></span> <a href="class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-input_all"><a href="#val-input_all" class="anchor"></a><code><span><span class="keyword">val</span> input_all : <span><span class="optlabel">?buf</span>:bytes <span class="arrow">-></span></span> <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> string</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-of_unix_fd"><a href="#val-of_unix_fd" class="anchor"></a><code><span><span class="keyword">val</span> of_unix_fd : <span><span class="optlabel">?close_noerr</span>:bool <span class="arrow">-></span></span> <span><span class="optlabel">?buf</span>:bytes <span class="arrow">-></span></span> <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span> <a href="class-type-t/index.html">t</a></span></code></div></div></div></body></html>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>t (moonpool-lwt.Moonpool_lwt.IO_out.t)</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-lwt</a> » <a href="../../index.html">Moonpool_lwt</a> » <a href="../index.html">IO_out</a> » t</nav><header class="odoc-preamble"><h1>Class type <code><span>IO_out.t</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec method anchored" id="method-output_char"><a href="#method-output_char" class="anchor"></a><code><span><span class="keyword">method</span> output_char : <span>char <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-output"><a href="#method-output" class="anchor"></a><code><span><span class="keyword">method</span> output : <span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-flush"><a href="#method-flush" class="anchor"></a><code><span><span class="keyword">method</span> flush : <span>unit <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec method anchored" id="method-close"><a href="#method-close" class="anchor"></a><code><span><span class="keyword">method</span> close : <span>unit <span class="arrow">-></span></span> unit</span></code></div></div></div></body></html>
|
||||
8
dev/moonpool-lwt/Moonpool_lwt/IO_out/index.html
Normal file
8
dev/moonpool-lwt/Moonpool_lwt/IO_out/index.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>IO_out (moonpool-lwt.Moonpool_lwt.IO_out)</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-lwt</a> » <a href="../index.html">Moonpool_lwt</a> » IO_out</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt.IO_out</span></code></h1><p>Output channel</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec class-type anchored" id="class-type-t"><a href="#class-type-t" class="anchor"></a><code><span><span class="keyword">class</span> <span class="keyword">type</span> </span><span><a href="class-type-t/index.html">t</a></span><span> = <span class="keyword">object</span> ... <span class="keyword">end</span></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="optlabel">?flush</span>:<span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?close</span>:<span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span><span class="label">output_char</span>:<span>(<span>char <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span><span class="label">output</span>:<span>(<span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span>unit <span class="arrow">-></span></span>
|
||||
<a href="class-type-t/index.html">t</a></span></code></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="class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-of_unix_fd"><a href="#val-of_unix_fd" class="anchor"></a><code><span><span class="keyword">val</span> of_unix_fd : <span><span class="optlabel">?close_noerr</span>:bool <span class="arrow">-></span></span> <span><span class="optlabel">?buf</span>:bytes <span class="arrow">-></span></span> <span><a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">-></span></span> <a href="class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-of_buffer"><a href="#val-of_buffer" class="anchor"></a><code><span><span class="keyword">val</span> of_buffer : <span><a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span> <a href="class-type-t/index.html">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-output_char"><a href="#val-output_char" class="anchor"></a><code><span><span class="keyword">val</span> output_char : <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> <span>char <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Output the buffer slice into this channel</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-output"><a href="#val-output" class="anchor"></a><code><span><span class="keyword">val</span> output : <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> <span>bytes <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Output the buffer slice into this channel</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-output_string"><a href="#val-output_string" class="anchor"></a><code><span><span class="keyword">val</span> output_string : <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> <span>string <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-output_line"><a href="#val-output_line" class="anchor"></a><code><span><span class="keyword">val</span> output_line : <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> <span>string <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-close"><a href="#val-close" class="anchor"></a><code><span><span class="keyword">val</span> close : <span><span>< close : <span>unit <span class="arrow">-></span></span> unit.. ></span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Close the channel.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-flush"><a href="#val-flush" class="anchor"></a><code><span><span class="keyword">val</span> flush : <span><span>< flush : <span>unit <span class="arrow">-></span></span> unit.. ></span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Flush (ie. force write) any buffered bytes.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-output_int"><a href="#val-output_int" class="anchor"></a><code><span><span class="keyword">val</span> output_int : <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-output_lines"><a href="#val-output_lines" class="anchor"></a><code><span><span class="keyword">val</span> output_lines : <span><a href="class-type-t/index.html">t</a> <span class="arrow">-></span></span> <span><span>string <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span> <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-tee"><a href="#val-tee" class="anchor"></a><code><span><span class="keyword">val</span> tee : <span><span><a href="class-type-t/index.html">t</a> list</span> <span class="arrow">-></span></span> <a href="class-type-t/index.html">t</a></span></code></div></div></div></body></html>
|
||||
5
dev/moonpool-lwt/Moonpool_lwt/TCP_client/index.html
Normal file
5
dev/moonpool-lwt/Moonpool_lwt/TCP_client/index.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>TCP_client (moonpool-lwt.Moonpool_lwt.TCP_client)</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-lwt</a> » <a href="../index.html">Moonpool_lwt</a> » TCP_client</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt.TCP_client</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-connect"><a href="#val-connect" class="anchor"></a><code><span><span class="keyword">val</span> connect : <span><a href="../../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a> <span class="arrow">-></span></span> <a href="../../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-with_connect"><a href="#val-with_connect" class="anchor"></a><code><span><span class="keyword">val</span> with_connect : <span><a href="../../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a> <span class="arrow">-></span></span> <span><span>(<span><a href="../IO_in/class-type-t/index.html">IO_in.t</a> <span class="arrow">-></span></span> <span><a href="../IO_out/class-type-t/index.html">IO_out.t</a> <span class="arrow">-></span></span> <span class="type-var">'a</span>)</span> <span class="arrow">-></span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p>Open a connection, and use <a href="../IO/index.html"><code>IO</code></a> to read and write from the socket in a non blocking way.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-with_connect_lwt"><a href="#val-with_connect_lwt" class="anchor"></a><code><span><span class="keyword">val</span> with_connect_lwt :
|
||||
<span><a href="../../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a> <span class="arrow">-></span></span>
|
||||
<span><span>(<span><a href="../../../lwt/Lwt_io/index.html#type-input_channel">Lwt_io.input_channel</a> <span class="arrow">-></span></span> <span><a href="../../../lwt/Lwt_io/index.html#type-output_channel">Lwt_io.output_channel</a> <span class="arrow">-></span></span> <span class="type-var">'a</span>)</span> <span class="arrow">-></span></span>
|
||||
<span class="type-var">'a</span></span></code></div><div class="spec-doc"><p>Open a connection.</p></div></div></div></body></html>
|
||||
14
dev/moonpool-lwt/Moonpool_lwt/TCP_server/index.html
Normal file
14
dev/moonpool-lwt/Moonpool_lwt/TCP_server/index.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>TCP_server (moonpool-lwt.Moonpool_lwt.TCP_server)</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-lwt</a> » <a href="../index.html">Moonpool_lwt</a> » TCP_server</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt.TCP_server</span></code></h1></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> = <a href="../../../lwt/Lwt_io/index.html#type-server">Lwt_io.server</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-establish_lwt"><a href="#val-establish_lwt" class="anchor"></a><code><span><span class="keyword">val</span> establish_lwt :
|
||||
<span><span class="optlabel">?backlog</span>:int <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?no_close</span>:bool <span class="arrow">-></span></span>
|
||||
<span><span class="label">runner</span>:<a href="../../../moonpool/Moonpool/Runner/index.html#type-t">Moonpool.Runner.t</a> <span class="arrow">-></span></span>
|
||||
<span><a href="../../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a> <span class="arrow">-></span></span>
|
||||
<span><span>(<span><a href="../../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a> <span class="arrow">-></span></span> <span><a href="../../../lwt/Lwt_io/index.html#type-input_channel">Lwt_io.input_channel</a> <span class="arrow">-></span></span> <span><a href="../../../lwt/Lwt_io/index.html#type-output_channel">Lwt_io.output_channel</a> <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>establish ~runner addr handler</code> runs a TCP server in the Lwt thread. When a client connects, a moonpool fiber is started on <code>runner</code> to handle it.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-establish"><a href="#val-establish" class="anchor"></a><code><span><span class="keyword">val</span> establish :
|
||||
<span><span class="optlabel">?backlog</span>:int <span class="arrow">-></span></span>
|
||||
<span><span class="optlabel">?no_close</span>:bool <span class="arrow">-></span></span>
|
||||
<span><span class="label">runner</span>:<a href="../../../moonpool/Moonpool/Runner/index.html#type-t">Moonpool.Runner.t</a> <span class="arrow">-></span></span>
|
||||
<span><a href="../../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a> <span class="arrow">-></span></span>
|
||||
<span><span>(<span><a href="../../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a> <span class="arrow">-></span></span> <span><a href="../IO_in/class-type-t/index.html">IO_in.t</a> <span class="arrow">-></span></span> <span><a href="../IO_out/class-type-t/index.html">IO_out.t</a> <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Like <a href="#val-establish_lwt"><code>establish_lwt</code></a> but uses <a href="../IO/index.html"><code>IO</code></a> to directly handle reads and writes on client sockets.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-shutdown"><a href="#val-shutdown" class="anchor"></a><code><span><span class="keyword">val</span> shutdown : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Shutdown the server</p></div></div></div></body></html>
|
||||
2
dev/moonpool-lwt/Moonpool_lwt/index.html
Normal file
2
dev/moonpool-lwt/Moonpool_lwt/index.html
Normal file
File diff suppressed because one or more lines are too long
2
dev/moonpool-lwt/Moonpool_lwt__/index.html
Normal file
2
dev/moonpool-lwt/Moonpool_lwt__/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Moonpool_lwt__ (moonpool-lwt.Moonpool_lwt__)</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-lwt</a> » Moonpool_lwt__</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt__</span></code></h1></header><div class="odoc-content"><p>This module is hidden.</p></div></body></html>
|
||||
2
dev/moonpool-lwt/Moonpool_lwt__Base/index.html
Normal file
2
dev/moonpool-lwt/Moonpool_lwt__Base/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Moonpool_lwt__Base (moonpool-lwt.Moonpool_lwt__Base)</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-lwt</a> » Moonpool_lwt__Base</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt__Base</span></code></h1></header><div class="odoc-content"><p>This module is hidden.</p></div></body></html>
|
||||
2
dev/moonpool-lwt/Moonpool_lwt__IO/index.html
Normal file
2
dev/moonpool-lwt/Moonpool_lwt__IO/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Moonpool_lwt__IO (moonpool-lwt.Moonpool_lwt__IO)</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-lwt</a> » Moonpool_lwt__IO</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt__IO</span></code></h1></header><div class="odoc-content"><p>This module is hidden.</p></div></body></html>
|
||||
2
dev/moonpool-lwt/Moonpool_lwt__IO_in/index.html
Normal file
2
dev/moonpool-lwt/Moonpool_lwt__IO_in/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Moonpool_lwt__IO_in (moonpool-lwt.Moonpool_lwt__IO_in)</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-lwt</a> » Moonpool_lwt__IO_in</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt__IO_in</span></code></h1></header><div class="odoc-content"><p>This module is hidden.</p></div></body></html>
|
||||
2
dev/moonpool-lwt/Moonpool_lwt__IO_out/index.html
Normal file
2
dev/moonpool-lwt/Moonpool_lwt__IO_out/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Moonpool_lwt__IO_out (moonpool-lwt.Moonpool_lwt__IO_out)</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-lwt</a> » Moonpool_lwt__IO_out</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt__IO_out</span></code></h1></header><div class="odoc-content"><p>This module is hidden.</p></div></body></html>
|
||||
2
dev/moonpool-lwt/Moonpool_lwt__Tcp_client/index.html
Normal file
2
dev/moonpool-lwt/Moonpool_lwt__Tcp_client/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Moonpool_lwt__Tcp_client (moonpool-lwt.Moonpool_lwt__Tcp_client)</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-lwt</a> » Moonpool_lwt__Tcp_client</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt__Tcp_client</span></code></h1></header><div class="odoc-content"><p>This module is hidden.</p></div></body></html>
|
||||
2
dev/moonpool-lwt/Moonpool_lwt__Tcp_server/index.html
Normal file
2
dev/moonpool-lwt/Moonpool_lwt__Tcp_server/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Moonpool_lwt__Tcp_server (moonpool-lwt.Moonpool_lwt__Tcp_server)</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-lwt</a> » Moonpool_lwt__Tcp_server</nav><header class="odoc-preamble"><h1>Module <code><span>Moonpool_lwt__Tcp_server</span></code></h1></header><div class="odoc-content"><p>This module is hidden.</p></div></body></html>
|
||||
103
dev/moonpool-lwt/_doc-dir/CHANGES.md
Normal file
103
dev/moonpool-lwt/_doc-dir/CHANGES.md
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
|
||||
# 0.5.1
|
||||
|
||||
- fix `Ws_pool`: workers would exit before processing
|
||||
all remaining tasks upon shutdown
|
||||
|
||||
# 0.5
|
||||
|
||||
## features
|
||||
|
||||
- add `Bb_queue.transfer`
|
||||
- add `Bb_queue.to_{iter,gen,seq}`
|
||||
- add `Fifo_pool`, a simple pool with a single blocking queue for
|
||||
workloads with coarse granularity tasks that value
|
||||
latency (e.g. a web server)
|
||||
- add a work-stealing pool for heavy compute workloads that
|
||||
feature a lot of await/fork-join, with a lot of help
|
||||
from Vesa Karvonen (@polytypic)
|
||||
- add `Fut.spawn_on_current_runner`
|
||||
- add `Runner.{spawn_on_current_runner, await}`
|
||||
- add a few more toplevel aliases in `Moonpool` itself
|
||||
- add `No_runner`: a runner that runs tasks synchronously in the caller
|
||||
- on shutdown, pools will finish running all present tasks before
|
||||
closing. New tasks are immediately rejected.
|
||||
|
||||
- use an optional dependency on `thread-local-storage` to
|
||||
implement work stealing and `spawn_on_current_runner`
|
||||
|
||||
## optimizations
|
||||
|
||||
- use the main domain to spawn threads on it. This means we can really
|
||||
use all cores, not all but one.
|
||||
- in `Fork_join.both`, only one of the two sides schedules a task,
|
||||
the other runs in the current thread. This reduces scheduling overhead.
|
||||
- compare to domainslib in benchmarks. With the WS pool we're now slightly
|
||||
ahead in terms of overhead on the recursive fib benchmark.
|
||||
|
||||
## breaking
|
||||
|
||||
- deprecate `Pool`, now an alias to `Fifo_pool`
|
||||
- the `Fut.Infix_local` and `Fut.infix` are gone, replaced with
|
||||
a simpler `Fut.Infix` module that tries to use the current runner
|
||||
for intermediate tasks.
|
||||
|
||||
# 0.4
|
||||
|
||||
- add `Fut.{reify_error,bind_reify_error}`
|
||||
- full lifecycle for worker domains, where a domain
|
||||
will shutdown if no thread runs on it, after a
|
||||
short delay.
|
||||
|
||||
- fix: generalize type of `create_arg`
|
||||
- perf: in `Bb_queue`, only signal condition on push if queue was empty
|
||||
|
||||
# 0.3
|
||||
|
||||
- add `Fork_join` for parallelizing computations. This is only
|
||||
available on OCaml 5.x because it relies on effects.
|
||||
- add `Fork_join.{for_,map_array,map_list}`
|
||||
- add `Fork_join.all_{list,init}`
|
||||
- add `Pool.with_`
|
||||
- add a channel module
|
||||
- add `Runner`, change `Pool` to produce a `Runner.t`
|
||||
- add a `Lock` module
|
||||
- add support for domain-local-await when installed
|
||||
- add `Fut.await` for OCaml >= 5.0
|
||||
|
||||
- fix: Fork_join.both_ignore now has a more general type
|
||||
|
||||
- expose `Suspend_` and its internal effect with an unstability alert.
|
||||
This is intended for implementors of `Runner` only.
|
||||
- port `cpp.ml` from containers, replace previous codegen with it.
|
||||
This will provide better flexibility for supporting multiple versions
|
||||
of OCaml in the future.
|
||||
- add `Pool.run_wait_block`; rename `Pool.run` into `Pool.run_async`
|
||||
- fix: in blocking queue, `pop` works on a non empty closed queue
|
||||
|
||||
# 0.2
|
||||
|
||||
- add `Fut.for_list`
|
||||
- add `around_task` to `Pool.create`
|
||||
- add `Pool.shutdown_without_waiting`
|
||||
- add `Pool.num_tasks`
|
||||
- add `Fut.is_done`
|
||||
- add `Blocking_queue.size`
|
||||
- add `Fut.for_array` to easily iterate on an array in parallel
|
||||
- add `Fut.get_or_fail{,_exn}`
|
||||
|
||||
- perf: limit number of work queues in pool
|
||||
- perf: use multiple queues and non-blocking work-stealing from them, in pool
|
||||
this improves the behavior for many small tasks by reducing contention on
|
||||
each queue
|
||||
|
||||
- fix: fut: actually run all map/bind callbacks in pool if provided
|
||||
|
||||
# 0.1.1
|
||||
|
||||
- fix(fut): fix bug when calling `wait_list []`
|
||||
- fix: join_array on arrays of length=1 had a bound error
|
||||
|
||||
# 0.1
|
||||
|
||||
initial release
|
||||
313
dev/moonpool-lwt/_doc-dir/README.md
Normal file
313
dev/moonpool-lwt/_doc-dir/README.md
Normal file
|
|
@ -0,0 +1,313 @@
|
|||
# Moonpool
|
||||
|
||||
[](https://github.com/c-cube/moonpool/actions/workflows/main.yml)
|
||||
|
||||
A pool within a bigger pool (ie the ocean). Here, we're talking about
|
||||
pools of `Thread.t` which live within a fixed pool of `Domain.t`.
|
||||
|
||||
This fixed pool of domains is shared between *all* the pools in moonpool.
|
||||
The rationale is that we should not have more domains than cores, so
|
||||
it's easier to pre-allocate exactly that many domains, and run more flexible
|
||||
thread pools on top.
|
||||
|
||||
In addition, some concurrency and parallelism primitives are provided:
|
||||
- `Moonpool.Fut` provides futures/promises that execute
|
||||
on these thread pools. The futures are thread safe.
|
||||
- `Moonpool.Chan` provides simple cooperative and thread-safe channels
|
||||
to use within pool-bound tasks. They're essentially re-usable futures.
|
||||
|
||||
On OCaml 5 (meaning there's actual domains and effects, not just threads),
|
||||
a `Fut.await` primitive is provided. It's simpler and more powerful
|
||||
than the monadic combinators.
|
||||
- `Moonpool_forkjoin`, in the library `moonpool.forkjoin`
|
||||
provides the fork-join parallelism primitives
|
||||
to use within tasks running in the pool.
|
||||
|
||||
## Usage
|
||||
|
||||
The user can create several thread pools (implementing the interface `Runner.t`).
|
||||
These pools use regular posix threads, but the threads are spread across
|
||||
multiple domains (on OCaml 5), which enables parallelism.
|
||||
|
||||
Current we provide these pool implementations:
|
||||
- `Fifo_pool` is a thread pool that uses a blocking queue to schedule tasks,
|
||||
which means they're picked in the same order they've been scheduled ("fifo").
|
||||
This pool is simple and will behave fine for coarse-granularity concurrency,
|
||||
but will slow down under heavy contention.
|
||||
- `Ws_pool` is a work-stealing pool, where each thread has its own local queue
|
||||
in addition to a global queue of tasks. This is efficient for workloads
|
||||
with many short tasks that spawn other tasks, but the order in which
|
||||
tasks are run is less predictable. This is useful when throughput is
|
||||
the important thing to optimize.
|
||||
|
||||
The function `Runner.run_async pool task` schedules `task()` to run on one of
|
||||
the workers of `pool`, as soon as one is available. No result is returned by `run_async`.
|
||||
|
||||
```ocaml
|
||||
# #require "threads";;
|
||||
# let pool = Moonpool.Fifo_pool.create ~num_threads:4 ();;
|
||||
val pool : Moonpool.Runner.t = <abstr>
|
||||
|
||||
# begin
|
||||
Moonpool.Runner.run_async pool
|
||||
(fun () ->
|
||||
Thread.delay 0.1;
|
||||
print_endline "running from the pool");
|
||||
print_endline "running from the caller";
|
||||
Thread.delay 0.3; (* wait for task to run before returning *)
|
||||
end ;;
|
||||
running from the caller
|
||||
running from the pool
|
||||
- : unit = ()
|
||||
```
|
||||
|
||||
To wait until the task is done, you can use `Runner.run_wait_block`[^1] instead:
|
||||
|
||||
[^1]: beware of deadlock! See documentation for more details.
|
||||
|
||||
```ocaml
|
||||
# begin
|
||||
Moonpool.Runner.run_wait_block pool
|
||||
(fun () ->
|
||||
Thread.delay 0.1;
|
||||
print_endline "running from the pool");
|
||||
print_endline "running from the caller (after waiting)";
|
||||
end ;;
|
||||
running from the pool
|
||||
running from the caller (after waiting)
|
||||
- : unit = ()
|
||||
```
|
||||
|
||||
The function `Fut.spawn ~on f` schedules `f ()` on the pool `on`, and immediately
|
||||
returns a _future_ which will eventually hold the result (or an exception).
|
||||
|
||||
The function `Fut.peek` will return the current value, or `None` if the future is
|
||||
still not completed.
|
||||
The functions `Fut.wait_block` and `Fut.wait_block_exn` will
|
||||
block the current thread and wait for the future to complete.
|
||||
There are some deadlock risks associated with careless use of these, so
|
||||
be sure to consult the documentation of the `Fut` module.
|
||||
|
||||
```ocaml
|
||||
# let fut = Moonpool.Fut.spawn ~on:pool
|
||||
(fun () ->
|
||||
Thread.delay 0.5;
|
||||
1+1);;
|
||||
val fut : int Moonpool.Fut.t = <abstr>
|
||||
|
||||
# Moonpool.Fut.peek fut;
|
||||
- : int Moonpool.Fut.or_error option = None
|
||||
|
||||
# Moonpool.Fut.wait_block_exn fut;;
|
||||
- : int = 2
|
||||
```
|
||||
|
||||
Some combinators on futures are also provided, e.g. to wait for all futures in
|
||||
an array to complete:
|
||||
|
||||
```ocaml
|
||||
# let rec fib x =
|
||||
if x <= 1 then 1 else fib (x-1) + fib (x-2);;
|
||||
val fib : int -> int = <fun>
|
||||
|
||||
# List.init 10 fib;;
|
||||
- : int list = [1; 1; 2; 3; 5; 8; 13; 21; 34; 55]
|
||||
|
||||
# let fibs = Array.init 35 (fun n -> Moonpool.Fut.spawn ~on:pool (fun () -> fib n));;
|
||||
val fibs : int Moonpool.Fut.t array =
|
||||
[|<abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>;
|
||||
<abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>;
|
||||
<abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>;
|
||||
<abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>;
|
||||
<abstr>; <abstr>; <abstr>|]
|
||||
|
||||
# Moonpool.Fut.join_array fibs |> Moonpool.Fut.wait_block;;
|
||||
- : int array Moonpool.Fut.or_error =
|
||||
Ok
|
||||
[|1; 1; 2; 3; 5; 8; 13; 21; 34; 55; 89; 144; 233; 377; 610; 987; 1597; 2584;
|
||||
4181; 6765; 10946; 17711; 28657; 46368; 75025; 121393; 196418; 317811;
|
||||
514229; 832040; 1346269; 2178309; 3524578; 5702887; 9227465|]
|
||||
```
|
||||
|
||||
### Support for `await`
|
||||
|
||||
On OCaml 5, effect handlers can be used to implement `Fut.await : 'a Fut.t -> 'a`.
|
||||
|
||||
The expression `Fut.await some_fut`, when run from inside some thread pool,
|
||||
suspends its caller task; the suspended task is then parked, and will
|
||||
be resumed when the future is completed.
|
||||
The pool worker that was executing this expression, in the mean time, moves
|
||||
on to another task.
|
||||
This means that `await` is free of the deadlock risks associated with
|
||||
`Fut.wait_block`.
|
||||
|
||||
In the following example, we bypass the need for `Fut.join_array` by simply
|
||||
using regular array functions along with `Fut.await`.
|
||||
|
||||
```ocaml
|
||||
# let main_fut =
|
||||
let open Moonpool.Fut in
|
||||
spawn ~on:pool @@ fun () ->
|
||||
(* array of sub-futures *)
|
||||
let tasks: _ Moonpool.Fut.t array = Array.init 100 (fun i ->
|
||||
spawn ~on:pool (fun () ->
|
||||
Thread.delay 0.01;
|
||||
i+1))
|
||||
in
|
||||
Array.fold_left (fun n fut -> n + await fut) 0 tasks
|
||||
;;
|
||||
val main_fut : int Moonpool.Fut.t = <abstr>
|
||||
|
||||
# let expected_sum = Array.init 100 (fun i->i+1) |> Array.fold_left (+) 0;;
|
||||
val expected_sum : int = 5050
|
||||
|
||||
# assert (expected_sum = Moonpool.Fut.wait_block_exn main_fut);;
|
||||
- : unit = ()
|
||||
```
|
||||
|
||||
### Fork-join
|
||||
|
||||
On OCaml 5, again using effect handlers, the sublibrary `moonpool.forkjoin`
|
||||
provides a module `Moonpool_forkjoin`
|
||||
implements the [fork-join model](https://en.wikipedia.org/wiki/Fork%E2%80%93join_model).
|
||||
It must run on a pool (using `Runner.run_async` or inside a future via `Fut.spawn`).
|
||||
|
||||
It is generally better to use the work-stealing pool for workloads that rely on
|
||||
fork-join for better performance, because fork-join will tend to spawn lots of
|
||||
shorter tasks.
|
||||
|
||||
Here is an simple example of a parallel sort.
|
||||
It uses selection sort for small slices, like this:
|
||||
|
||||
```ocaml
|
||||
# let rec select_sort arr i len =
|
||||
if len >= 2 then (
|
||||
let idx = ref i in
|
||||
for j = i+1 to i+len-1 do
|
||||
if arr.(j) < arr.(!idx) then idx := j
|
||||
done;
|
||||
let tmp = arr.(!idx) in
|
||||
arr.(!idx) <- arr.(i);
|
||||
arr.(i) <- tmp;
|
||||
select_sort arr (i+1) (len-1)
|
||||
);;
|
||||
val select_sort : 'a array -> int -> int -> unit = <fun>
|
||||
```
|
||||
|
||||
And a parallel quicksort for larger slices:
|
||||
|
||||
```ocaml
|
||||
# let rec quicksort arr i len : unit =
|
||||
if len <= 10 then select_sort arr i len
|
||||
else (
|
||||
let pivot = arr.(i + (len / 2)) in
|
||||
let low = ref (i - 1) in
|
||||
let high = ref (i + len) in
|
||||
|
||||
(* partition the array slice *)
|
||||
while !low < !high do
|
||||
incr low;
|
||||
decr high;
|
||||
while arr.(!low) < pivot do
|
||||
incr low
|
||||
done;
|
||||
while arr.(!high) > pivot do
|
||||
decr high
|
||||
done;
|
||||
if !low < !high then (
|
||||
let tmp = arr.(!low) in
|
||||
arr.(!low) <- arr.(!high);
|
||||
arr.(!high) <- tmp
|
||||
)
|
||||
done;
|
||||
|
||||
(* sort lower half and upper half in parallel *)
|
||||
Moonpool_forkjoin.both_ignore
|
||||
(fun () -> quicksort arr i (!low - i))
|
||||
(fun () -> quicksort arr !low (len - (!low - i)))
|
||||
);;
|
||||
val quicksort : 'a array -> int -> int -> unit = <fun>
|
||||
|
||||
|
||||
# let arr = [| 4;2;1;5;1;10;3 |];;
|
||||
val arr : int array = [|4; 2; 1; 5; 1; 10; 3|]
|
||||
# Moonpool.Fut.spawn
|
||||
~on:pool (fun () -> quicksort arr 0 (Array.length arr))
|
||||
|> Moonpool.Fut.wait_block_exn;;
|
||||
- : unit = ()
|
||||
# arr;;
|
||||
- : int array = [|1; 1; 2; 3; 4; 5; 10|]
|
||||
|
||||
|
||||
# let arr =
|
||||
let rand = Random.State.make [| 42 |] in
|
||||
Array.init 40 (fun _-> Random.State.int rand 300);;
|
||||
val arr : int array =
|
||||
[|64; 220; 247; 196; 51; 186; 22; 106; 58; 58; 11; 161; 243; 111; 74; 109;
|
||||
49; 135; 59; 192; 132; 38; 19; 44; 126; 147; 182; 83; 95; 231; 204; 121;
|
||||
142; 255; 72; 85; 95; 93; 73; 202|]
|
||||
# Moonpool.Fut.spawn ~on:pool
|
||||
(fun () -> quicksort arr 0 (Array.length arr))
|
||||
|> Moonpool.Fut.wait_block_exn
|
||||
;;
|
||||
- : unit = ()
|
||||
# arr;;
|
||||
- : int array =
|
||||
[|11; 19; 22; 38; 44; 49; 51; 58; 58; 59; 64; 72; 73; 74; 83; 85; 93; 95; 95;
|
||||
106; 109; 111; 121; 126; 132; 135; 142; 147; 161; 182; 186; 192; 196; 202;
|
||||
204; 220; 231; 243; 247; 255|]
|
||||
```
|
||||
|
||||
Note that the sort had to be started in a task (via `Moonpool.Fut.spawn`)
|
||||
so that fork-join would run on the thread pool.
|
||||
This is necessary even for the initial iteration because fork-join
|
||||
relies on OCaml 5's effects, meaning that the computation needs to run
|
||||
inside an effect handler provided by the thread pool.
|
||||
|
||||
### More intuition
|
||||
|
||||
To quote [gasche](https://discuss.ocaml.org/t/ann-moonpool-0-1/12387/15):
|
||||
|
||||
<blockquote>
|
||||
You are assuming that, if pool P1 has 5000 tasks, and pool P2 has 10 other tasks, then these 10 tasks will get to run faster than if we just added them at the end of pool P1. This sounds like a “fairness” assumption: separate pools will get comparable shares of domain compute ressources, or at least no pool will be delayed too much from running their first tasks.
|
||||
|
||||
[…]
|
||||
|
||||
- each pool uses a fixed number of threads, all running simultaneously; if there are more tasks sent to the pool, they are delayed and will only get one of the pool threads when previous tasks have finished
|
||||
- separate pools run their separate threads simultaneously, so they compete for compute resources on their domain using OCaml’s systhreads scheduler – which does provide fairness in practice
|
||||
- as a result, running in a new pool enables quicker completion than adding to an existing pool (as we will be scheduled right away instead of waiting for previous tasks in our pool to free some threads)
|
||||
- the ratio of compute resources that each pool gets should be roughly proportional to its number of worker threads
|
||||
</blockquote>
|
||||
|
||||
## OCaml versions
|
||||
|
||||
This works for OCaml >= 4.08.
|
||||
- On OCaml 4.xx, there are no domains, so this is just a library for regular thread pools
|
||||
with not actual parallelism (except for threads that call C code that releases the runtime lock, that is).
|
||||
C calls that do release the runtime lock (e.g. to call [Z3](https://github.com/Z3Prover/z3), hash a file, etc.)
|
||||
will still run in parallel.
|
||||
- on OCaml 5.xx, there is a fixed pool of domains (using the recommended domain count).
|
||||
These domains do not do much by themselves, but we schedule new threads on them, and form pools
|
||||
of threads that contain threads from each domain.
|
||||
Each domain might thus have multiple threads that belong to distinct pools (and several threads from
|
||||
the same pool, too — this is useful for threads blocking on IO); Each pool will have threads
|
||||
running on distinct domains, which enables parallelism.
|
||||
|
||||
A useful analogy is that each domain is a bit like a CPU core, and `Thread.t` is a logical thread running on a core.
|
||||
Multiple threads have to share a single core and do not run in parallel on it[^2].
|
||||
We can therefore build pools that spread their worker threads on multiple cores to enable parallelism within each pool.
|
||||
|
||||
TODO: actually use https://github.com/haesbaert/ocaml-processor to pin domains to cores,
|
||||
possibly optionally using `select` in dune.
|
||||
|
||||
## License
|
||||
|
||||
MIT license.
|
||||
|
||||
## Install
|
||||
|
||||
```sh, skip
|
||||
$ opam install moonpool
|
||||
```
|
||||
|
||||
[^2]: ignoring hyperthreading for the sake of the analogy.
|
||||
2
dev/moonpool-lwt/index.html
Normal file
2
dev/moonpool-lwt/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>index (moonpool-lwt.index)</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> – moonpool-lwt</nav><header class="odoc-preamble"><h1 id="package-moonpool-lwt"><a href="#package-moonpool-lwt" class="anchor"></a>Package moonpool-lwt <nav><a type="text/plain; charset=UTF-8" href="_doc-dir/CHANGES.md">changes</a> <a href="#package_info">more…</a></nav></h1><ul class="modules"><li><a href="Moonpool_lwt/index.html"><code>Moonpool_lwt</code></a> <span class="synopsis">Lwt_engine-based event loop for Moonpool.</span></li></ul></header><nav class="odoc-toc"><ul><li><a href="#package_info">Package info</a></li></ul></nav><div class="odoc-content"><h2 id="package_info"><a href="#package_info" class="anchor"></a>Package info</h2><table class="package info"><tr id="info-changes-files"><td><a href="#info-changes-files" aria-hidden="true" class="anchor"></a>changes-files</td><td><ul><li><a type="text/plain; charset=UTF-8" href="_doc-dir/CHANGES.md">CHANGES.md</a></li></ul></td></tr><tr id="info-readme-files"><td><a href="#info-readme-files" aria-hidden="true" class="anchor"></a>readme-files</td><td><ul><li><a type="text/plain; charset=UTF-8" href="_doc-dir/README.md">README.md</a></li></ul></td></tr></table></div></body></html>
|
||||
|
|
@ -3,6 +3,6 @@
|
|||
<span><span class="label">size</span>:<span>(<span>unit <span class="arrow">-></span></span> int)</span> <span class="arrow">-></span></span>
|
||||
<span><span class="label">num_tasks</span>:<span>(<span>unit <span class="arrow">-></span></span> int)</span> <span class="arrow">-></span></span>
|
||||
<span><span class="label">shutdown</span>:<span>(<span><span class="label">wait</span>:bool <span class="arrow">-></span></span> <span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span><span class="label">run_async</span>:<span>(<span><span class="label">name</span>:string <span class="arrow">-></span></span> <span><span class="label">ls</span>:<a href="../../Task_local_storage/index.html#type-storage">Task_local_storage.storage</a> <span class="arrow">-></span></span> <span><a href="../index.html#type-task">task</a> <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span><span class="label">run_async</span>:<span>(<span><span class="label">ls</span>:<a href="../../Task_local_storage/index.html#type-storage">Task_local_storage.storage</a> <span class="arrow">-></span></span> <span><a href="../index.html#type-task">task</a> <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||||
<span>unit <span class="arrow">-></span></span>
|
||||
<a href="../index.html#type-t">t</a></span></code></div><div class="spec-doc"><p>Create a new runner.</p><p><b>NOTE</b>: the runner should support DLA and <code>Suspend_</code> on OCaml 5.x, so that <code>Fork_join</code> and other 5.x features work properly.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-k_cur_runner"><a href="#val-k_cur_runner" class="anchor"></a><code><span><span class="keyword">val</span> k_cur_runner : <span><span><span><a href="../index.html#type-t">t</a> option</span> <a href="../../../../ocaml/Stdlib/index.html#type-ref">ref</a></span> <a href="../../../Moonpool_private/Thread_local_storage_/index.html#type-key">Moonpool_private.Thread_local_storage_.key</a></span></span></code></div><div class="spec-doc"><p>Key that should be used by each runner to store itself in TLS on every thread it controls, so that tasks running on these threads can access the runner. This is necessary for <a href="../index.html#val-get_current_runner"><code>get_current_runner</code></a> to work.</p></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
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue