mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
2 lines
4.3 KiB
HTML
2 lines
4.3 KiB
HTML
<!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 3.1.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../../index.html">Index</a> » <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>
|