moonpool/dev/ocaml/Stdlib/Domain/DLS/index.html
2023-08-29 18:39:53 +00:00

2 lines
No EOL
3.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>DLS (ocaml.Stdlib.Domain.DLS)</title><link rel="stylesheet" href="../../../../_odoc-theme/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.1"/><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">ocaml</a> &#x00BB; <a href="../../index.html">Stdlib</a> &#x00BB; <a href="../index.html">Domain</a> &#x00BB; DLS</nav><header class="odoc-preamble"><h1>Module <code><span>Domain.DLS</span></code></h1><p>Domain-local Storage</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-key"><a href="#type-key" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a key</span></span></code></div><div class="spec-doc"><p>Type of a DLS key</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-new_key"><a href="#val-new_key" class="anchor"></a><code><span><span class="keyword">val</span> new_key : <span>?split_from_parent:<span>(<span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span> <span><span>(<span>unit <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="#type-key">key</a></span></span></code></div><div class="spec-doc"><p><code>new_key f</code> returns a new key bound to initialiser <code>f</code> for accessing domain-local variables.</p><p>If <code>split_from_parent</code> is provided, spawning a domain will derive the child value (for this key) from the parent value.</p><p>Note that the <code>split_from_parent</code> call is computed in the parent domain, and is always computed regardless of whether the child domain will use it. If the splitting function is expensive or requires client-side computation, consider using <code>'a Lazy.t key</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get"><a href="#val-get" class="anchor"></a><code><span><span class="keyword">val</span> get : <span><span><span class="type-var">'a</span> <a href="#type-key">key</a></span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p><code>get k</code> returns <code>v</code> if a value <code>v</code> is associated to the key <code>k</code> on the calling domain's domain-local state. Sets <code>k</code>'s value with its initialiser and returns it otherwise.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-set"><a href="#val-set" class="anchor"></a><code><span><span class="keyword">val</span> set : <span><span><span class="type-var">'a</span> <a href="#type-key">key</a></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>set k v</code> updates the calling domain's domain-local state to associate the key <code>k</code> with value <code>v</code>. It overwrites any previous values associated to <code>k</code>, which cannot be restored later.</p></div></div></div></body></html>