linol/lwt/Lwt_gc/index.html
2025-08-24 01:27:17 +00:00

2 lines
2.4 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>Lwt_gc (lwt.Lwt_gc)</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> &#x00BB; <a href="../index.html">lwt</a> &#x00BB; Lwt_gc</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_gc</span></code></h1><p>Interaction with the garbage collector</p></header><div class="odoc-content"><p>This module offers a convenient way to add a finaliser launching a thread to a value, without having to use <code>Lwt_unix.run</code> in the finaliser.</p><div class="odoc-spec"><div class="spec value anchored" id="val-finalise"><a href="#val-finalise" class="anchor"></a><code><span><span class="keyword">val</span> finalise : <span><span>(<span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>finalise f x</code> ensures <code>f x</code> is evaluated after <code>x</code> has been garbage collected. If <code>f x</code> yields, then Lwt will wait for its termination at the end of the program.</p><p>Note that <code>f x</code> is not called at garbage collection time, but later in the main loop.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-finalise_or_exit"><a href="#val-finalise_or_exit" class="anchor"></a><code><span><span class="keyword">val</span> finalise_or_exit : <span><span>(<span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>finalise_or_exit f x</code> call <code>f x</code> when <code>x</code> is garbage collected or (exclusively) when the program exits.</p></div></div></div></body></html>