package lwt

  1. Overview
  2. Docs
Promises and event-driven I/O

Install

dune-project
 Dependency

Authors

Maintainers

Sources

5.7.0.tar.gz
md5=737039d29d45b2d2b35db6931c8d75c6
sha512=42e629920783428673b99c9d7a639237c9e6b35079b5d907bc67e7ea506acf9edadc48cec580bdcfd2410ed9412bf5e6bcc8b09de2fa7d35ce1490973d05ddd1

doc/lwt/Lwt_mvar/index.html

Module Lwt_mvarSource

Mailbox variables

“Mailbox” variables implement a synchronising variable, used for communication between concurrent threads.

Sourcetype 'a t

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.

Sourceval create : 'a -> 'a t

create v creates a new mailbox variable containing value v.

Sourceval create_empty : unit -> 'a t

create () creates a new empty mailbox variable.

Sourceval put : 'a t -> 'a -> unit Lwt.t

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.

Sourceval take : 'a t -> 'a Lwt.t

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.

Sourceval take_available : 'a t -> 'a option

take_available mvar immediately takes the value from mvar without blocking, returning None if the mailbox is empty.

  • since 3.2.0
Sourceval is_empty : 'a t -> bool

is_empty mvar indicates if put mvar can be called without blocking.

  • since 3.2.0