TMVar: Transactional MVars, for use in the STM monad (GHC only)
A TMVar is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.
Put a value into an MVar. If the MVar is currently full, putMVar will wait until it becomes empty.
There are two further important properties of putMVar:
* putMVar is single-wakeup. That is, if there are multiple threads blocked in putMVar, and the MVar becomes empty, only one thread will be woken up. The runtime guarantees that the woken thread completes its putMVar operation.
* When multiple threads are blocked on an MVar, they are woken up in FIFO order. This is useful for providing fairness properties of abstractions built using MVars.
A non-blocking version of putMVar. The tryPutMVar function attempts to put the value a into the MVar, returning True if it was successful, or False otherwise.
Check whether a given TMVar is empty.
Create a TMVar which is initially empty.
Create a TMVar which contains the supplied value.
This is a combination of takeTMVar and putTMVar; ie. it takes the value from the TMVar, puts it back, and also returns it.
Swap the contents of a TMVar for a new value.
A version of readTMVar which does not retry. Instead it returns Nothing if no value is available.