ocaml-containers/dev/containers-thread/CCTimer/index.html
2022-02-08 18:12:01 +00:00

2 lines
No EOL
6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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 2.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">containers-thread</a> &#x00BB; CCTimer</nav><header class="odoc-preamble"><h1>Module <code><span>CCTimer</span></code></h1></header><nav class="odoc-toc"><ul><li><a href="#event-timer">Event timer</a></li></ul></nav><div class="odoc-content"><h2 id="event-timer"><a href="#event-timer" class="anchor"></a>Event timer</h2><p>Used to be part of <code>CCFuture</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.16</li></ul><div class="odoc-spec"><div class="spec type" id="type-t" class="anchored"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span></code></div><div class="spec-doc"><p>A scheduler for events. It runs in its own thread.</p></div></div><div class="odoc-spec"><div class="spec value" id="val-create" class="anchored"><a href="#val-create" class="anchor"></a><code><span><span class="keyword">val</span> create : <span>unit <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>A new timer.</p></div></div><div class="odoc-spec"><div class="spec value" id="val-set_exn_handler" class="anchored"><a href="#val-set_exn_handler" class="anchor"></a><code><span><span class="keyword">val</span> set_exn_handler : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><span>( <span>exn <span class="arrow">&#45;&gt;</span></span> unit )</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><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></div></div><div class="odoc-spec"><div class="spec exception" id="exception-Stopped" class="anchored"><a href="#exception-Stopped" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Stopped</span></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-after" class="anchored"><a href="#val-after" class="anchor"></a><code><span><span class="keyword">val</span> after : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>float <span class="arrow">&#45;&gt;</span></span> <span>f:<span>( <span>unit <span class="arrow">&#45;&gt;</span></span> <span class="type-var">_</span> )</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Call the callback <code>f</code> after the given number of seconds.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Stopped</span> <p>if the timer was stopped.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value" id="val-at" class="anchored"><a href="#val-at" class="anchor"></a><code><span><span class="keyword">val</span> at : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>float <span class="arrow">&#45;&gt;</span></span> <span>f:<span>( <span>unit <span class="arrow">&#45;&gt;</span></span> <span class="type-var">_</span> )</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Create a future that evaluates to <code>()</code> at the given Unix timestamp.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Stopped</span> <p>if the timer was stopped.</p></li></ul></div></div><div class="odoc-spec"><div class="spec exception" id="exception-ExitEvery" class="anchored"><a href="#exception-ExitEvery" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">ExitEvery</span></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-every" class="anchored"><a href="#val-every" class="anchor"></a><code><span><span class="keyword">val</span> every : <span>?delay:float <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>float <span class="arrow">&#45;&gt;</span></span> <span>f:<span>( <span>unit <span class="arrow">&#45;&gt;</span></span> <span class="type-var">_</span> )</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><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><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">delay</span> <p>if provided, the first call to <code>f ()</code> is delayed by that many seconds.</p></li></ul><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Stopped</span> <p>if the timer was stopped.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value" id="val-stop" class="anchored"><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">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Stop the given timer, cancelling pending tasks. Idempotent. From now on, calling most other operations on the timer will raise Stopped.</p></div></div><div class="odoc-spec"><div class="spec value" id="val-active" class="anchored"><a href="#val-active" class="anchor"></a><code><span><span class="keyword">val</span> active : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p>Return <code>true</code> until <code>stop t</code> has been called.</p></div></div></div></body></html>