Module Cell.Once

Set-once immutable cells.

A set-once immutable cell is a cell that can be set exactly once:

Cells

type 'a t

The type for set-once immutable cells.

val make : unit -> 'a t

make () is a new set-once immutable cell.

val from_val : 'a -> 'a t

from_val v is a cell already set to v.

val try_set : 'a t -> 'a -> unit

try_set cell v attempts to set cell to v if not already set.

val try_set_is_ours : 'a t -> 'a -> bool

try_set_is_ours cell v attempts to set cell to v and returns:

  • true if the cell was unset and set to v by the call.
  • false if the cell was already set, in which case nothing happened.
val get : 'a t -> 'a

get cell blocks until cell's value is set to v and continues with v.

Predicates

val is_set : 'a t -> bool

is_set cell is true if and only if cell is set.

Actions

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

get' cell is the action for get. An action invocation is permanently enabled and synchronizes with v once the cell has been set to v.