package picos_std
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=862d61383e2df93a876bedcffb1fd1ddc0f96c50b0e9c07943a2aee1f0e182be
sha512=87805379017ef4a7f2c11b954625a3757a0f1431bb9ba59132202de278b3e41adbe0cdc20e3ab23b7c9a8c5a15faeb7ec79348e7d80f2b14274b00df0893b8c0
doc/picos_std.sync/Picos_std_sync/Lazy/index.html
Module Picos_std_sync.Lazy
Source
A lazy suspension.
ℹ️ 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))
.