dejafu-0.1.0.0: Overloadable primitives for testable, potentially non-deterministic, concurrency.

Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Concurrent.STM.CTMVar

Contents

Description

Transactional CVars, for use with MonadSTM.

Synopsis

CTMVars

data CTMVar m a Source

A CTMVar is like an MVar or a CVar, but using transactional memory. As transactions are atomic, this makes dealing with multiple CTMVars easier than wrangling multiple CVars.

newCTMVar :: MonadSTM m => a -> m (CTMVar m a) Source

Create a CTMVar containing the given value.

newEmptyCTMVar :: MonadSTM m => m (CTMVar m a) Source

Create a new empty CTMVar.

takeCTMVar :: MonadSTM m => CTMVar m a -> m a Source

Take the contents of a CTMVar, or retry if it is empty.

putCTMVar :: MonadSTM m => CTMVar m a -> a -> m () Source

Write to a CTMVar, or retry if it is full.

readCTMVar :: MonadSTM m => CTMVar m a -> m a Source

Read from a CTMVar without emptying, or retry if it is empty.

tryTakeCTMVar :: MonadSTM m => CTMVar m a -> m (Maybe a) Source

Try to take the contents of a CTMVar, returning Nothing if it is empty.

tryPutCTMVar :: MonadSTM m => CTMVar m a -> a -> m Bool Source

Try to write to a CTMVar, returning False if it is full.

tryReadCTMVar :: MonadSTM m => CTMVar m a -> m (Maybe a) Source

Try to read from a CTMVar without emptying, returning Nothing if it is empty.

isEmptyCTMVar :: MonadSTM m => CTMVar m a -> m Bool Source

Check if a CTMVar is empty or not.

swapCTMVar :: MonadSTM m => CTMVar m a -> a -> m a Source

Swap the contents of a CTMVar returning the old contents, or retry if it is empty.