Skip to content

Commit

Permalink
deploy: 06f3bda
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Dec 4, 2024
1 parent 86dfc5d commit 192d46d
Show file tree
Hide file tree
Showing 28 changed files with 1,323 additions and 42 deletions.
2 changes: 1 addition & 1 deletion lwt/Lwt/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
Lwt_io.printl "Only 2 more seconds passed")))
end

(* ocamlfind opt -linkpkg -thread -package lwt.unix code.ml &amp;&amp; ./a.out *)</code></pre><p>And that's it! Concurrency in Lwt is simply a matter of whether you start an operation in the callback of another one or not. As a convenience, Lwt provides a few <a href="#2_Concurrency" title="2_Concurrency">helpers</a> for common concurrency patterns.</p><h4 id="3_Executionmodel"><a href="#3_Executionmodel" class="anchor"></a>Execution model</h4><p>It's important to understand that promises are a pure-OCaml data type. They don't do any fancy scheduling or I/O. They are just lists of callbacks (if pending), or containers for one value (if resolved).</p><p>The interesting function is <a href="../Lwt_main/index.html#val-run"><code>Lwt_main.run</code></a>. It's a wrapper around <a href="http://man7.org/linux/man-pages/man2/select.2.html"><code>select(2)</code></a>, <a href="http://man7.org/linux/man-pages/man7/epoll.7.html"><code>epoll(7)</code></a>, <a href="https://www.freebsd.org/cgi/man.cgi?query=kqueue&amp;sektion=2"><code>kqueue(2)</code></a>, or whatever asynchronous I/O API your system provides. On browsers, the work of <a href="../Lwt_main/index.html#val-run"><code>Lwt_main.run</code></a> is done by the surrounding JavaScript engine, so you don't call <a href="../Lwt_main/index.html#val-run"><code>Lwt_main.run</code></a> from inside your program. But the execution model is still the same, and the description below applies!</p><p>To avoid writing out “underlying asynchronous I/O API,” we'll assume, in this section, that the API is <code>select(2)</code>. That's just for the sake of abbreviation. It doesn't actually matter, for most purposes, what the underlying I/O API is.</p><p>Let's use the program from the tutorial that reads two lines as an example. Here it is, again, in its desugared form:</p><pre class="language-ocaml"><code>let () =
(* ocamlfind opt -linkpkg -thread -package lwt.unix code.ml &amp;&amp; ./a.out *)</code></pre><p>And that's it! Concurrency in Lwt is simply a matter of whether you start an operation in the callback of another one or not. As a convenience, Lwt provides a few <a href="#2_Concurrency" title="2_Concurrency">helpers</a> for common concurrency patterns.</p><h4 id="3_Executionmodel"><a href="#3_Executionmodel" class="anchor"></a>Execution model</h4><p>It's important to understand that promises are a pure-OCaml data type. They don't do any fancy scheduling or I/O. They are just lists of callbacks (if pending), or containers for one value (if resolved).</p><p>The interesting function is <a href="../Lwt_main/index.html#val-run"><code>Lwt_main.run</code></a>. It's a wrapper around <a href="https://man7.org/linux/man-pages/man2/select.2.html"><code>select(2)</code></a>, <a href="https://man7.org/linux/man-pages/man7/epoll.7.html"><code>epoll(7)</code></a>, <a href="https://man.freebsd.org/cgi/man.cgi?query=kqueue&amp;sektion=2"><code>kqueue(2)</code></a>, or whatever asynchronous I/O API your system provides. On browsers, the work of <a href="../Lwt_main/index.html#val-run"><code>Lwt_main.run</code></a> is done by the surrounding JavaScript engine, so you don't call <a href="../Lwt_main/index.html#val-run"><code>Lwt_main.run</code></a> from inside your program. But the execution model is still the same, and the description below applies!</p><p>To avoid writing out “underlying asynchronous I/O API,” we'll assume, in this section, that the API is <code>select(2)</code>. That's just for the sake of abbreviation. It doesn't actually matter, for most purposes, what the underlying I/O API is.</p><p>Let's use the program from the tutorial that reads two lines as an example. Here it is, again, in its desugared form:</p><pre class="language-ocaml"><code>let () =
let p : unit Lwt.t =
let line_1_promise : string Lwt.t = Lwt_io.(read_line stdin) in
Lwt.bind line_1_promise (fun (line_1 : string) -&gt;
Expand Down
2 changes: 1 addition & 1 deletion lwt/Lwt_engine/Ev_backend/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +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.3"/><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> &#x00BB; <a href="../index.html">Lwt_engine</a> &#x00BB; 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">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div></div></div></body></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.3"/><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> &#x00BB; <a href="../index.html">Lwt_engine</a> &#x00BB; 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-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">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</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">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div></div></div></body></html>
2 changes: 1 addition & 1 deletion lwt/Lwt_engine/Versioned/class-libev_1/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +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.3"/><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> &#x00BB; <a href="../../index.html">Lwt_engine</a> &#x00BB; <a href="../index.html">Versioned</a> &#x00BB; 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>
<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.3"/><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> &#x00BB; <a href="../../index.html">Lwt_engine</a> &#x00BB; <a href="../index.html">Versioned</a> &#x00BB; 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-backend"><a href="#method-backend" class="anchor"></a><code><span><span class="keyword">method</span> backend : <a href="../../Ev_backend/index.html#type-t">Ev_backend.t</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 changes: 1 addition & 1 deletion lwt/Lwt_engine/Versioned/class-libev_2/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +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.3"/><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> &#x00BB; <a href="../../index.html">Lwt_engine</a> &#x00BB; <a href="../index.html">Versioned</a> &#x00BB; 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>
<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.3"/><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> &#x00BB; <a href="../../index.html">Lwt_engine</a> &#x00BB; <a href="../index.html">Versioned</a> &#x00BB; 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-backend"><a href="#method-backend" class="anchor"></a><code><span><span class="keyword">method</span> backend : <a href="../../Ev_backend/index.html#type-t">Ev_backend.t</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>
Loading

0 comments on commit 192d46d

Please sign in to comment.