mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
2 lines
No EOL
4.4 KiB
HTML
2 lines
No EOL
4.4 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>CCTimer (containers-thread.CCTimer)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.3"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> – <a href="../index.html">containers-thread</a> » CCTimer</nav><h1>Module <code>CCTimer</code></h1><h2 id="event-timer"><a href="#event-timer" class="anchor"></a>Event timer</h2><p>Used to be part of <code>CCFuture</code>.</p><dl><dt>since</dt><dd>0.16</dd></dl></header><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> t</code></dt><dd><p>A scheduler for events. It runs in its own thread.</p></dd></dl><dl><dt class="spec value" id="val-create"><a href="#val-create" class="anchor"></a><code><span class="keyword">val</span> create : unit <span>-></span> <a href="index.html#type-t">t</a></code></dt><dd><p>A new timer.</p></dd></dl><dl><dt class="spec value" id="val-set_exn_handler"><a href="#val-set_exn_handler" class="anchor"></a><code><span class="keyword">val</span> set_exn_handler : <a href="index.html#type-t">t</a> <span>-></span> <span>(exn <span>-></span> unit)</span> <span>-></span> unit</code></dt><dd><p><code>set_exn_handler timer f</code> registers <code>f</code> so that any exception raised by a task scheduled in <code>timer</code> is given to <code>f</code>.</p></dd></dl><dl><dt class="spec exception" id="exception-Stopped"><a href="#exception-Stopped" class="anchor"></a><code><span class="keyword">exception</span> </code><code><span class="exception">Stopped</span></code></dt></dl><dl><dt class="spec value" id="val-after"><a href="#val-after" class="anchor"></a><code><span class="keyword">val</span> after : <a href="index.html#type-t">t</a> <span>-></span> float <span>-></span> <span>f:<span>(unit <span>-></span> <span class="type-var">_</span>)</span></span> <span>-></span> unit</code></dt><dd><p>Call the callback <code>f</code> after the given number of seconds.</p><dl><dt>raises Stopped</dt><dd><p>if the timer was stopped.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-at"><a href="#val-at" class="anchor"></a><code><span class="keyword">val</span> at : <a href="index.html#type-t">t</a> <span>-></span> float <span>-></span> <span>f:<span>(unit <span>-></span> <span class="type-var">_</span>)</span></span> <span>-></span> unit</code></dt><dd><p>Create a future that evaluates to <code>()</code> at the given Unix timestamp.</p><dl><dt>raises Stopped</dt><dd><p>if the timer was stopped.</p></dd></dl></dd></dl><dl><dt class="spec exception" id="exception-ExitEvery"><a href="#exception-ExitEvery" class="anchor"></a><code><span class="keyword">exception</span> </code><code><span class="exception">ExitEvery</span></code></dt></dl><dl><dt class="spec value" id="val-every"><a href="#val-every" class="anchor"></a><code><span class="keyword">val</span> every : <span>?⁠delay:float</span> <span>-></span> <a href="index.html#type-t">t</a> <span>-></span> float <span>-></span> <span>f:<span>(unit <span>-></span> <span class="type-var">_</span>)</span></span> <span>-></span> unit</code></dt><dd><p><code>every timer n ~f</code> calls <code>f ()</code> every <code>n</code> seconds. <code>f()</code> can raise ExitEvery to stop the cycle.</p><dl><dt>parameter delay</dt><dd><p>if provided, the first call to <code>f ()</code> is delayed by that many seconds.</p></dd></dl><dl><dt>raises Stopped</dt><dd><p>if the timer was stopped.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-stop"><a href="#val-stop" class="anchor"></a><code><span class="keyword">val</span> stop : <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p>Stop the given timer, cancelling pending tasks. Idempotent. From now on, calling most other operations on the timer will raise Stopped.</p></dd></dl><dl><dt class="spec value" id="val-active"><a href="#val-active" class="anchor"></a><code><span class="keyword">val</span> active : <a href="index.html#type-t">t</a> <span>-></span> bool</code></dt><dd><p>Return <code>true</code> until <code>stop t</code> has been called.</p></dd></dl></div></body></html> |