nanoev/picos/Picos/Computation/Tx/index.html
2025-05-05 14:16:16 +00:00

7 lines
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>Tx (picos.Picos.Computation.Tx)</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">Computation</a> &#x00BB; Tx</nav><header class="odoc-preamble"><h1>Module <code><span>Computation.Tx</span></code></h1><p>Transactional interface for atomically completing multiple computations.</p><p>⚠️ The implementation of this mechanism is designed to avoid making the single computation completing operations, i.e. <a href="../index.html#val-try_return" title="Computation.try_return"><code>try_return</code></a> and <a href="../index.html#val-try_cancel" title="Computation.try_cancel"><code>try_cancel</code></a>, slower and to avoid making computations heavier. For this reason the transaction mechanism is only <a href="https://en.wikipedia.org/wiki/Non-blocking_algorithm#Obstruction-freedom">obstruction-free</a>. What this means is that a transaction may be aborted by another transaction or by a single computation manipulating operation.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type subst anchored" id="type-computation"><a href="#type-computation" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a computation</span></span><span> := <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Destructively substituted alias for <a href="../index.html#type-t"><code>Computation.t</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-same"><a href="#val-same" class="anchor"></a><code><span><span class="keyword">val</span> same : <span><span><span class="type-var">_</span> <a href="#type-computation">computation</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">_</span> <a href="#type-computation">computation</a></span> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>same computation1 computation2</code> determines whether the two computations are the one and the same.</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> t</span></code></div><div class="spec-doc"><p>Represents a transaction.</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> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>create ()</code> returns a new empty transaction.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-try_return"><a href="#val-try_return" class="anchor"></a><code><span><span class="keyword">val</span> try_return : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-computation">computation</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>try_return tx computation value</code> adds the completion of the <code>computation</code> as having returned the given <code>value</code> to the transaction. Returns <code>true</code> in case the computation had not yet been completed and the transaction was still alive. Otherwise returns <code>false</code> which means that transaction was aborted and it is as if none of the completions succesfully added to the transaction have taken place.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-try_cancel"><a href="#val-try_cancel" class="anchor"></a><code><span><span class="keyword">val</span> try_cancel :
<span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span><span class="type-var">'a</span> <a href="#type-computation">computation</a></span> <span class="arrow">&#45;&gt;</span></span>
<span>exn <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../../../ocaml/Stdlib/Printexc/index.html#type-raw_backtrace">Stdlib.Printexc.raw_backtrace</a> <span class="arrow">&#45;&gt;</span></span>
bool</span></code></div><div class="spec-doc"><p><code>try_cancel tx computation exn bt</code> adds the completion of the computation as having canceled with the given exception and backtrace to the transaction. Returns <code>true</code> in case the computation had not yet been completed and the transaction was still alive. Otherwise returns <code>false</code> which means that transaction was aborted and it is as if none of the completions succesfully added to the transaction have taken place.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-try_commit"><a href="#val-try_commit" class="anchor"></a><code><span><span class="keyword">val</span> try_commit : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>try_commit tx</code> attempts to mark the transaction as committed successfully. Returns <code>true</code> in case of success, which means that all the completions added to the transaction have been performed atomically. Otherwise returns <code>false</code> which means that transaction was aborted and it is as if none of the completions succesfully added to the transaction have taken place.</p></div></div></div></body></html>