package mvar

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 'a t
val create_empty : unit -> 'a t

Create an empty mvar.

val create : 'a -> 'a t

Create an mvar containing a value.

val take : 'a t -> 'a

Wait until mvar holds a value, then return it and leave the mvar empty.

val try_take : 'a t -> 'a option

Non-blocking take - if the mvar holds no value, return None.

val put : 'a t -> 'a -> unit

Wait until the mvar is empty, then put the supplied value in the mvar.

val try_put : 'a t -> 'a -> bool

Non-blocking put - if the mvar is empty the put the supplied value in the mvar, otherwise return false.

val is_empty : 'a t -> bool

Test whether the mvar is empty.

val swap : 'a t -> 'a -> 'a

Wait until the mvar is populated, then put the supplied value in the mvar and return the previous value.

val modify : 'a t -> ('a -> 'a) -> unit

Wait until the mvar is populated, then use the supplied function to modify its value.

OCaml

Innovation. Community. Security.