package picos
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=343a8b4759239ca0c107145b8e2cc94c14625fecc0b0887d3c40a9ab7537b8da
sha512=db22b0a5b3adc603c0e815c9011c779f892b9ace76be018b2198d3e24a7d96727c999701025fe5a5fd07d0b452cb7286fc50c939aba0e4dce809941e9ebc12a6
doc/picos.sync/Picos_sync/Lazy/index.html
Module Picos_sync.Lazy
Source
A lazy implementation for Picos
.
ℹ️ This intentionally mimics the interface of Stdlib.Lazy
. Unlike with the standard library suspensions an attempt to force a suspension from multiple fibers, possibly running on different domains, does not raise the Undefined
exception.
Synonym for Stdlib.Lazy.Undefined
.
Represents a deferred computation or suspension.
from_val value
returns an already forced suspension whose result is the given value
.
is_val susp
determines whether the suspension has already been forced and didn't raise an exception.
force susp
forces the suspension, i.e. computes thunk ()
using the thunk
passed to from_fun
, stores the result of the computation to the suspension and reproduces its result. In case the suspension has already been forced the computation is skipped and stored result is reproduced.
ℹ️ This will check whether the current fiber has been canceled before starting the computation of thunk ()
. This allows the suspension to be forced by another fiber. However, if the fiber is canceled and the cancelation exception is raised after the computation has been started, the suspension will then store the cancelation exception.
map fn susp
is equivalent to from_fun (fun () -> fn (force susp))
.