Module Lwt_mvar
Mailbox variables
type 'a tThe type of a mailbox variable. Mailbox variables are used to communicate values between threads in a synchronous way. The type parameter specifies the type of the value propagated from
puttotake.
val create : 'a -> 'a tcreate vcreates a new mailbox variable containing valuev.
val create_empty : unit -> 'a tcreate ()creates a new empty mailbox variable.
val put : 'a t -> 'a -> unit Lwt.tput mvar valueputs a value into a mailbox variable. This value will remain in the mailbox untiltakeis called to remove it. If the mailbox is not empty, the current thread will block until it is emptied.
val take : 'a t -> 'a Lwt.ttake mvarwill take any currently available value from the mailbox variable. If no value is currently available, the current thread will block, awaiting a value to beputby another thread.
val take_available : 'a t -> 'a optiontake_available mvarimmediately takes the value frommvarwithout blocking, returningNoneif the mailbox is empty.- since
- 3.2.0
val is_empty : 'a t -> boolis_empty mvarindicates ifput mvarcan be called without blocking.- since
- 3.2.0