package picos
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=0f2dcc67ddd127c68f388f2c36a8725a15723e6aeba7d1ddfcf4e016b54a4674
sha512=bee2a99458a451be285e2f13cc3a9deda8eed4e118bcdfc51c256d2da5bae92eec3386c318fe42dcf451421543b519dc064967158b3f417c9b7b44ce97c5fb75
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 stadard 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))