package picos_std

  1. Overview
  2. Docs

An incremental or single-assignment poisonable variable.

type !'a t

Represents an incremental variable.

val create : unit -> 'a t

create () returns a new empty incremental variable.

val of_value : 'a -> 'a t

of_value value returns an incremental variable prefilled with the given value.

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

try_fill ivar value attempts to assign the given value to the incremental variable. Returns true on success and false in case the variable had already been poisoned or assigned a value.

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

fill ivar value is equivalent to try_fill ivar value |> ignore.

val try_poison : 'a t -> exn -> Printexc.raw_backtrace -> bool

try_poison ivar exn bt attempts to poison the incremental variable with the specified exception and backtrace. Returns true on success and false in case the variable had already been poisoned or assigned a value.

val poison : 'a t -> exn -> Printexc.raw_backtrace -> unit

poison ivar exn bt is equivalent to try_poison ivar exn bt |> ignore.

val peek_opt : 'a t -> 'a option

peek_opt ivar either returns Some value in case the variable has been assigned the value, raises an exception in case the variable has been poisoned, or otherwise returns None, which means that the variable has not yet been poisoned or assigned a value.

val read : 'a t -> 'a

read ivar waits until the variable is either assigned a value or the variable is poisoned and then returns the value or raises the exception.

val read_evt : 'a t -> 'a Picos_std_event.Event.t

read_evt ivar returns an event that can be committed to once the variable has either been assigned a value or has been poisoned.

OCaml

Innovation. Community. Security.