stm-lifted-2.5.0.0: Software Transactional Memory lifted to MonadIO

Safe HaskellSafe
LanguageHaskell2010

Control.Concurrent.STM.TMVar.Lifted

Synopsis

Documentation

mkWeakTMVar :: TMVar a -> IO () -> IO (Weak (TMVar a)) #

Make a Weak pointer to a TMVar, using the second argument as a finalizer to run when the TMVar is garbage-collected.

Since: stm-2.4.4

isEmptyTMVar :: TMVar a -> STM Bool #

Check whether a given TMVar is empty.

swapTMVar :: TMVar a -> a -> STM a #

Swap the contents of a TMVar for a new value.

tryReadTMVar :: TMVar a -> STM (Maybe a) #

A version of readTMVar which does not retry. Instead it returns Nothing if no value is available.

Since: stm-2.3

readTMVar :: TMVar a -> STM a #

This is a combination of takeTMVar and putTMVar; ie. it takes the value from the TMVar, puts it back, and also returns it.

tryPutTMVar :: TMVar a -> a -> STM Bool #

A version of putTMVar that does not retry. The tryPutTMVar function attempts to put the value a into the TMVar, returning True if it was successful, or False otherwise.

putTMVar :: TMVar a -> a -> STM () #

Put a value into a TMVar. If the TMVar is currently full, putTMVar will retry.

tryTakeTMVar :: TMVar a -> STM (Maybe a) #

A version of takeTMVar that does not retry. The tryTakeTMVar function returns Nothing if the TMVar was empty, or Just a if the TMVar was full with contents a. After tryTakeTMVar, the TMVar is left empty.

takeTMVar :: TMVar a -> STM a #

Return the contents of the TMVar. If the TMVar is currently empty, the transaction will retry. After a takeTMVar, the TMVar is left empty.

newEmptyTMVar :: STM (TMVar a) #

Create a TMVar which is initially empty.

newTMVar :: a -> STM (TMVar a) #

Create a TMVar which contains the supplied value.

data TMVar a #

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.

Instances
Eq (TMVar a) 
Instance details

Defined in Control.Concurrent.STM.TMVar

Methods

(==) :: TMVar a -> TMVar a -> Bool #

(/=) :: TMVar a -> TMVar a -> Bool #

newTMVarIO :: MonadIO m => a -> m (TMVar a) Source #

takeTMVarIO :: MonadIO m => TMVar a -> m a Source #

putTMVarIO :: MonadIO m => TMVar a -> a -> m () Source #

readTMVarIO :: MonadIO m => TMVar a -> m a Source #

swapTMVarIO :: MonadIO m => TMVar a -> a -> m a Source #

tryPutTMVarIO :: MonadIO m => TMVar a -> a -> m Bool Source #