Classes
The following classes are available globally.
-
An
MVar
(pronounced “em-var”) is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.An
MVar<A>
is mutable location that is either empty or contains a value of typeA
. It has two fundamental operations:put(_:)
which fills anMVar
if it is empty and blocks otherwise, andtake()
which empties anMVar
if it is full and blocks otherwise. They can be used in multiple different ways:- As synchronized mutable variables,
- As channels, with
take()
andput(_:)
as receive and send, and - As a binary semaphore
MVar<Void>
, withtake()
andput(_:)
as wait and signal.
Declaration
Swift
public final class MVar<A>