package lwt

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

Install

dune-project
 Dependency

Authors

Maintainers

Sources

5.5.0.tar.gz
md5=94272fac89c5bf21a89c102b8a8f35a5
sha512=8951b94555e930634375816d71815b9d85daad6ffb7dab24864661504d11be26575ab0b237196c54693efa372a9b69cdc1d5068a20a250dc0bbb4a3c03c5fda1

doc/lwt/Lwt_mvar/index.html

Module Lwt_mvar

Mailbox variables

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

type '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.

val create : 'a -> 'a t

create v creates a new mailbox variable containing value v.

val create_empty : unit -> 'a t

create () creates a new empty mailbox variable.

val 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.

val 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.

val 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
val is_empty : 'a t -> bool

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

  • since 3.2.0