nanoev/picos/Picos/Fiber/FLS/index.html
2025-05-05 14:16:16 +00:00

2 lines
6.7 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>FLS (picos.Picos.Fiber.FLS)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.0.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">picos</a> &#x00BB; <a href="../../index.html">Picos</a> &#x00BB; <a href="../index.html">Fiber</a> &#x00BB; FLS</nav><header class="odoc-preamble"><h1>Module <code><span>Fiber.FLS</span></code></h1><p>Fiber local storage</p><p>Fiber local storage is intended for use as a low overhead storage mechanism for fiber extensions. For example, one might associate a priority value with each fiber for a scheduler that uses a priority queue or one might use FLS to store unique id values for fibers.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type subst anchored" id="type-fiber"><a href="#type-fiber" class="anchor"></a><code><span><span class="keyword">type</span> fiber</span><span> := <a href="../index.html#type-t">t</a></span></code></div><div class="spec-doc"><p>Destructively substituted alias for <a href="../index.html#type-t"><code>Fiber.t</code></a>.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a t</span></span></code></div><div class="spec-doc"><p>Represents a key for storing values of type <code>'a</code> in storage associated with fibers.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-create"><a href="#val-create" class="anchor"></a><code><span><span class="keyword">val</span> create : <span>unit <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>create ()</code> allocates a new key for associating values in storage associated with fibers.</p><p>⚠️ New keys should not be created dynamically.</p></div></div><div class="odoc-spec"><div class="spec exception anchored" id="exception-Not_set"><a href="#exception-Not_set" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Not_set</span></span></code></div><div class="spec-doc"><p>Raised by <a href="#val-get_exn"><code>get_exn</code></a> in case value has not been <a href="#val-set"><code>set</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_exn"><a href="#val-get_exn" class="anchor"></a><code><span><span class="keyword">val</span> get_exn : <span><a href="#type-fiber">fiber</a> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-t">t</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_exn fiber key</code> returns the value associated with the <code>key</code> in the storage associated with the <code>fiber</code> or raises <a href="#exception-Not_set"><code>Not_set</code></a> using <code>raise_notrace</code>.</p><p>⚠️ It is only safe to call <code>get_exn</code> from the fiber itself or when the fiber is known not to be running.</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><a href="#type-fiber">fiber</a> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span class="label">default</span>:<span class="type-var">'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 fiber key ~default</code> returns the value associated with the <code>key</code> in the storage associated with the <code>fiber</code> or the <code>default</code> value.</p><p>⚠️ It is only safe to call <code>get</code> from the fiber itself or when the fiber is known not to be running.</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><a href="#type-fiber">fiber</a> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-t">t</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 fiber key value</code> sets the <code>value</code> associated with the <code>key</code> to the given value in the storage associated with the <code>fiber</code>.</p><p>⚠️ It is only safe to call <code>set</code> from the fiber itself or when the fiber is known not to be running.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove"><a href="#val-remove" class="anchor"></a><code><span><span class="keyword">val</span> remove : <span><a href="#type-fiber">fiber</a> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>remove fiber key</code> removes the value, if any, associated with the <code>key</code> from the storage associated with the <code>fiber</code>.</p><p>⚠️ It is only safe to call <code>remove</code> from the fiber itself or when the fiber is known not to be running.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-reserve"><a href="#val-reserve" class="anchor"></a><code><span><span class="keyword">val</span> reserve : <span><a href="#type-fiber">fiber</a> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-t">t</a></span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>reserve fiber key</code> ensures that sufficient space has been allocated to associate a value with the specified <code>key</code> such that a subsequent <a href="#val-set"><code>set</code></a> with the <code>key</code> will not allocate.</p><p> This can be used to optimize the population of the FLS and to avoid performing memory allocations in critical sections.</p><p>⚠️ It is only safe to call <code>reserve</code> from the fiber itself or when the fiber is known not to be running.</p></div></div></div></body></html>