package lwt
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=749bfda935744ee2954a7c03dd6c1a523f2100a2818592dbf6eaf6d6a9798bbc
md5=8bfc70c2944020fa08dd04877747f5f9
doc/lwt/Lwt_mvar/index.html
Module Lwt_mvar
Mailbox variables
"Mailbox" variables implement a synchronising variable, used for communication between concurrent threads.
This code adapted from Comparing lightweight threads (eigenclass.org)
The 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 put to take.
val create : 'a -> 'a tcreate v creates a new mailbox variable containing value v.
val create_empty : unit -> 'a tcreate () creates a new empty mailbox variable.
put mvar value puts a value into a mailbox variable. This value will remain in the mailbox until take is called to remove it. If the mailbox is not empty, the current thread will block until it is emptied.
take mvar will take any currently available value from the mailbox variable. If no value is currently available, the current thread will block, awaiting a value to be put by another thread.
val take_available : 'a t -> 'a optiontake_available mvar immediately takes the value from mvar without blocking, returning None if the mailbox is empty.
val is_empty : 'a t -> boolis_empty mvar indicates if put mvar can be called without blocking.