Files

3 lines
2.5 KiB
HTML
Raw Permalink 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>Leak_handler (capnp-rpc.Capnp_rpc.Leak_handler)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../odoc.support/odoc.css"/><meta name="generator" content="odoc 2.4.4"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../odoc.support/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">capnp-rpc</a> &#x00BB; <a href="../index.html">Capnp_rpc</a> &#x00BB; Leak_handler</nav><header class="odoc-preamble"><h1>Module <code><span>Capnp_rpc.Leak_handler</span></code></h1><p>Handle references that got GC'd with a non-zero ref-count.</p><p>If an application forgets to release a resource and it gets GC'd then we want to log a warning and clean up (so forgotten refs don't build up over time).</p><p>Because GC finalizers can run at any time and from any thread, we need to pass the cleanup callback to a fiber running in the owning thread.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-run"><a href="#val-run" class="anchor"></a><code><span><span class="keyword">val</span> run : <span>unit <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p><code>run ()</code> registers a leak handler for the current thread and runs a loop that waits for callbacks and runs them. If the fiber is cancelled, the handler is removed.</p><p>Each vat runs this in a daemon fiber. It is safe to have multiple such fibers running in a single systhread.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-ref_leak_detected"><a href="#val-ref_leak_detected" class="anchor"></a><code><span><span class="keyword">val</span> ref_leak_detected : <span>int <span class="arrow">&#45;&gt;</span></span> <span><span>(<span>unit <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>ref_leak_detected thread_id fn</code> should be called from a GC finalizer if the resource was not properly released.</p><p>If a handler for <code>thread_id</code> is running (see <a href="#val-run"><code>run</code></a>) then it will schedule <code>fn</code> to run at a safe point in that thread. If not, <code>fn</code> is ignored.</p></div></div></div></body></html>