Module Await_sync.Ivar

A write-once cell that can be empty or full (i.e., hold a single value).

type !'a t
val create : unit -> 'a t @@ portable

create () returns an empty ivar.

val create_full : 'a @ portable contended -> 'a t @@ portable

create_full v returns an ivar filled with v.

val fill_exn : 'a t @ local -> ('a @ portable contended -> unit) @ local @@ portable

fill_exn t v fills t with value v if t was empty.

val fill_if_empty : 'a t @ local -> ('a @ portable contended -> unit) @ local @@ portable

fill_if_empty t v fills t with value v if t was empty. Otherwise does nothing.

val read : Await_kernel.Await.t @ local -> ('a t @ local -> 'a @ portable contended) @ local @@ portable

read w t waits until the ivar t is filled and returns the value v after the ivar is filled with v.

  • raises Terminated

    in case w was terminated.

val read_or_cancel : Await_kernel.Await.t @ local -> (Await_kernel.Cancellation.t @ local -> ('a t @ local -> 'a Await_kernel.Or_canceled.t @ contended) @ local) @ local @@ portable

read_or_cancel w c t is Completed (read w t) if c was not canceled, otherwise it is Canceled.

  • raises Terminated

    in case w was terminated, even if c was canceled.

val peek : 'a t @ local -> 'a or_null @ contended @@ portable

peek t returns This v iff t is full with value v, or Null if t is not full.