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>Lwt_timeout (lwt.Lwt_timeout)</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">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>
|