package picos_std

  1. Overview
  2. Docs
Sample libraries for Picos

Install

Dune Dependency

Authors

Maintainers

Sources

picos-0.5.0.tbz
sha256=862d61383e2df93a876bedcffb1fd1ddc0f96c50b0e9c07943a2aee1f0e182be
sha512=87805379017ef4a7f2c11b954625a3757a0f1431bb9ba59132202de278b3e41adbe0cdc20e3ab23b7c9a8c5a15faeb7ec79348e7d80f2b14274b00df0893b8c0

doc/picos_std.sync/Picos_std_sync/Lazy/index.html

Module Picos_std_sync.LazySource

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.

Sourceexception Undefined
Sourcetype !'a t

Represents a deferred computation or suspension.

Sourceval from_fun : (unit -> 'a) -> 'a t

from_fun thunk returns a suspension.

Sourceval from_val : 'a -> 'a t

from_val value returns an already forced suspension whose result is the given value.

Sourceval is_val : 'a t -> bool

is_val susp determines whether the suspension has already been forced and didn't raise an exception.

Sourceval force : 'a t -> 'a

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.

  • raises Undefined

    in case the suspension is currently being forced by the current fiber.

Sourceval force_val : 'a t -> 'a

force_val is a synonym for force.

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

map fn susp is equivalent to from_fun (fun () -> fn (force susp)).

Sourceval map_val : ('a -> 'b) -> 'a t -> 'b t

map_val fn susp is equivalent to:

  if is_val susp then
    from_val (fn (force susp))
  else
    map fn susp
OCaml

Innovation. Community. Security.