Picos_std_sync.Ivar
An incremental or single-assignment poisonable 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_at : 'a t -> exn -> Stdlib.Printexc.raw_backtrace -> bool
try_poison_at 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.
ℹ️ This operation is not cancelable.
val try_poison : ?callstack:int -> 'a t -> exn -> bool
try_poison ivar exn
is equivalent to try_poison_at ivar exn (Printexc.get_callstack n)
where n
defaults to 0
.
val poison_at : 'a t -> exn -> Stdlib.Printexc.raw_backtrace -> unit
poison_at ivar exn bt
is equivalent to try_poison_at ivar exn bt |> ignore
.
val poison : ?callstack:int -> 'a t -> exn -> unit
poison ivar exn
is equivalent to poison_at ivar exn (Printexc.get_callstack n)
where n
defaults to 0
.
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.