| Copyright | (c) 2016 Michael Walker |
|---|---|
| License | MIT |
| Maintainer | Michael Walker <mike@barrucadu.co.uk> |
| Stability | stable |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Control.Concurrent.Classy.STM.TVar
Contents
Description
Transactional variables, for use with MonadSTM.
Deviations: There is no Eq instance for MonadSTM the TVar
type. Furthermore, the newTVarIO and mkWeakTVar functions are
not provided.
- newTVar :: MonadSTM stm => a -> stm (TVar stm a)
- newTVarN :: MonadSTM stm => String -> a -> stm (TVar stm a)
- readTVar :: MonadSTM stm => TVar stm a -> stm a
- readTVarConc :: MonadConc m => TVar (STM m) a -> m a
- writeTVar :: MonadSTM stm => TVar stm a -> a -> stm ()
- modifyTVar :: MonadSTM stm => TVar stm a -> (a -> a) -> stm ()
- modifyTVar' :: MonadSTM stm => TVar stm a -> (a -> a) -> stm ()
- swapTVar :: MonadSTM stm => TVar stm a -> a -> stm a
- registerDelay :: MonadConc m => Int -> m (TVar (STM m) Bool)
TVars
newTVar :: MonadSTM stm => a -> stm (TVar stm a) Source #
Create a new TVar containing the given value.
newTVar = newTVarN ""
newTVarN :: MonadSTM stm => String -> a -> stm (TVar stm a) Source #
Create a new TVar containing the given value, but it is
given a name which may be used to present more useful debugging
information.
If an empty name is given, a counter starting from 0 is used. If
names conflict, successive TVars with the same name are given
a numeric suffix, counting up from 1.
newTVarN _ = newTVar
readTVarConc :: MonadConc m => TVar (STM m) a -> m a Source #
Read the current value stored in a TVar. This may be
implemented differently for speed.
readTVarConc = atomically . readTVar
writeTVar :: MonadSTM stm => TVar stm a -> a -> stm () Source #
Write the supplied value into the TVar.
modifyTVar :: MonadSTM stm => TVar stm a -> (a -> a) -> stm () Source #
Mutate the contents of a TVar. This is non-strict.
modifyTVar' :: MonadSTM stm => TVar stm a -> (a -> a) -> stm () Source #
Mutate the contents of a TVar strictly.
swapTVar :: MonadSTM stm => TVar stm a -> a -> stm a Source #
Swap the contents of a TVar, returning the old value.
registerDelay :: MonadConc m => Int -> m (TVar (STM m) Bool) Source #
Set the value of returned TVar to True after a given number
of microseconds. The caveats associated with threadDelay also
apply.