Module Cell.Lazy

Lazy immutable cells.

A lazy immutable cell is an immutable cell whose content is computed exactly once:

Cells

type 'a t

The type for lazy immutable cells.

val make : (unit -> 'a) -> 'a t

make f is a new lazy cell computed with f () by the first function that calls force l.

val from_val : 'a -> 'a t

from_val v is a lazy cell already forced to v.

val from_exn : exn -> Stdlib.Printexc.raw_backtrace -> 'a t

from_exn exn bt is a lazy cell already forced to the exception exn with backtrace bt.

val force : 'a t -> 'a

force cell blocks until cell's value (or exception) is computed and continues with it. The first caller to force on cell doesn't block, it executes the thunk and continues with the result.

Predicates

val is_forced : 'a t -> bool

is_forced cell is true if and only if cell has been forced.

val is_val : 'a t -> bool

is_val cell is true if and only if cell has been forced and did not raise an exception.

Actions

val force' : 'a t -> 'a Action.t

force' cell is the action for force. An action invocation is permanently enabled and synchronizes with the cell's value (or exception) once it has been computed by the first action invocation.