Module Ccell.Mvar


module Mvar: sig .. end
Mutable shared variable.

This module provides mutable inter-thread variable and it's opeerations.


type 'a t 
Mutable shared variable.
val make : unit -> 'a t
make () makes an empty mutable shared variable.
val init_make : 'a -> 'a t
init_make x makes a mvar initialy has x.
val read : 'a t -> 'a Ccell.Event.event
read m returns a value from m. Blocked if i is empty.
val take : 'a t -> 'a Ccell.Event.event
Almost same as read, but take operation makes m empty.
val put : 'a t -> 'a -> unit Ccell.Event.event
put m v puts the value v to varible m when it's empty. If the variable m is full, blocked until the variable be empty by other threads.
val replace : 'a t -> ('a -> 'a) -> unit Ccell.Event.event
replace m fn replaces the mvared value. The commit point is first take operation. During replace, read, take operations are blocked.