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.
Modulerelude-1.2.0.0Haskell2010
Relude.Lifted.Concurrent
SPDX-License-Identifier : MIT Maintainer : Kowainik xrom.xkov@gmail.com Stability : Stable Portability : Portable
- 4 types
- 31 values
- Packagerelude-1.2.0.0
- Exports35
- LanguageHaskell2010
- LicenceMIT
- SourceConcurrent.hs
MVar
10 declarationsLifted to MonadIO version of newEmptyMVar.
Lifted to MonadIO version of tryPutMVar.
Lifted to MonadIO version of tryReadMVar.
Lifted to MonadIO version of tryTakeMVar.
STM
4 declarationsA monad supporting atomic memory transactions.
Instances11Monad, Functor, MonadFix, Applicative, Alternative, MonadPlus, …
Monad STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncFunctor STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncMonadFix STMDefined in stm-2.5.3.1 · Control.Monad.STM · orphanApplicative STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncAlternative STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncMonadPlus STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncMonadCatch STMDefined in exceptions-0.10.9 · Control.Monad.CatchMonadThrow STMDefined in exceptions-0.10.9 · Control.Monad.CatchMArray TArray e STMDefined in stm-2.5.3.1 · Control.Concurrent.STM.TArraySemigroup a => Semigroup (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncMonoid a => Monoid (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
Lifted to MonadIO version of atomically.
A variant of throw that can only be used within the STM monad.
Throwing an exception in STM aborts the transaction and propagates the
exception. If the exception is caught via catchSTM, only the changes
enclosed by the catch are rolled back; changes made outside of catchSTM
persist.
If the exception is not caught inside of the STM, it is re-thrown by atomically, and the entire STM is rolled back.
Although throwSTM has a type that is an instance of the type of throw, the two functions are subtly different:
throw e `seq` x ===> throw e
throwSTM e `seq` x ===> xThe first example will cause the exception e to be raised,
whereas the second one won't. In fact, throwSTM will only cause
an exception to be raised when it is used within the STM monad.
The throwSTM variant should be used in preference to throw to
raise an exception within the STM monad because it guarantees
ordering with respect to other STM operations, whereas throw
does not.
TVar
7 declarationsShared memory locations that support atomic memory transactions.
Lifted to MonadIO version of readTVarIO.
Strict version of modifyTVar.
Create a new TVar holding a value supplied
Return the current value stored in a TVar.
Write the supplied value into a TVar.
TMVar
14 declarationsA 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.
Create a TMVar which contains the supplied value.
Create a TMVar which is initially empty.
Lifted to MonadIO version of newTMVarIO.
Lifted to MonadIO version of newEmptyTMVarIO.
A version of readTMVar which does not retry. Instead it
returns Nothing if no value is available.
Swap the contents of a TMVar for a new value.
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.
Check whether a given TMVar is empty.