package affect

  1. Overview
  2. Docs

Module Cell.OnceSource

Set-once immutable cells.

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

  • A Once.try_set sets the value of the cell if still unset.
  • A Once.get blocks until the value of the cell is set.

Cells

Sourcetype 'a t

The type for set-once immutable cells.

Sourceval make : unit -> 'a t

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

Sourceval from_val : 'a -> 'a t

from_val v is a cell already set to v.

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

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

Sourceval 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.
Sourceval get : 'a t -> 'a

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

Predicates

Sourceval is_set : 'a t -> bool

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

Actions

Sourceval 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.