universum-1.7.3: Custom prelude used in Serokell
Safe HaskellSafe
LanguageHaskell2010

Universum.Lifted.Concurrent

Contents

Description

Concurrency useful and common functions.

Synopsis

MVar

data MVar a #

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.

Instances

Instances details
NFData1 MVar

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf :: (a -> ()) -> MVar a -> () #

Eq (MVar a)

Since: base-4.1.0.0

Instance details

Defined in GHC.MVar

Methods

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

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

NFData (MVar a)

NOTE: Only strict in the reference and not the referenced value.

Since: deepseq-1.4.2.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: MVar a -> () #

newEmptyMVar :: MonadIO m => m (MVar a) Source #

Lifted to MonadIO version of newEmptyMVar.

newMVar :: MonadIO m => a -> m (MVar a) Source #

Lifted to MonadIO version of newMVar.

putMVar :: MonadIO m => MVar a -> a -> m () Source #

Lifted to MonadIO version of putMVar.

readMVar :: MonadIO m => MVar a -> m a Source #

Lifted to MonadIO version of readMVar.

swapMVar :: MonadIO m => MVar a -> a -> m a Source #

Lifted to MonadIO version of swapMVar.

takeMVar :: MonadIO m => MVar a -> m a Source #

Lifted to MonadIO version of takeMVar.

tryPutMVar :: MonadIO m => MVar a -> a -> m Bool Source #

Lifted to MonadIO version of tryPutMVar.

tryReadMVar :: MonadIO m => MVar a -> m (Maybe a) Source #

Lifted to MonadIO version of tryReadMVar.

tryTakeMVar :: MonadIO m => MVar a -> m (Maybe a) Source #

Lifted to MonadIO version of tryTakeMVar.

updateMVar' :: MonadIO m => MVar s -> StateT s IO a -> m a Source #

Like modifyMVar, but modification is specified as a State computation.

This method is strict in produced s value.

STM

data STM a #

A monad supporting atomic memory transactions.

Instances

Instances details
Monad STM

Since: base-4.3.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

(>>=) :: STM a -> (a -> STM b) -> STM b #

(>>) :: STM a -> STM b -> STM b #

return :: a -> STM a #

Functor STM

Since: base-4.3.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

fmap :: (a -> b) -> STM a -> STM b #

(<$) :: a -> STM b -> STM a #

Applicative STM

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

pure :: a -> STM a #

(<*>) :: STM (a -> b) -> STM a -> STM b #

liftA2 :: (a -> b -> c) -> STM a -> STM b -> STM c #

(*>) :: STM a -> STM b -> STM b #

(<*) :: STM a -> STM b -> STM a #

Alternative STM

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

empty :: STM a #

(<|>) :: STM a -> STM a -> STM a #

some :: STM a -> STM [a] #

many :: STM a -> STM [a] #

MonadPlus STM

Since: base-4.3.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

mzero :: STM a #

mplus :: STM a -> STM a -> STM a #

MonadThrow STM 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> STM a #

MonadCatch STM 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => STM a -> (e -> STM a) -> STM a #

data TVar a #

Shared memory locations that support atomic memory transactions.

Instances

Instances details
Eq (TVar a)

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

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

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

atomically :: MonadIO m => STM a -> m a Source #

Lifted to MonadIO version of atomically.

newTVarIO :: MonadIO m => a -> m (TVar a) Source #

Lifted to MonadIO version of newTVarIO.

readTVarIO :: MonadIO m => TVar a -> m a Source #

Lifted to MonadIO version of readTVarIO.

modifyTVar' :: TVar a -> (a -> a) -> STM () #

Strict version of modifyTVar.

Since: stm-2.3

updateTVar' :: TVar s -> StateT s STM a -> STM a Source #

Like 'modifyTVar'', but modification is specified as a State monad.

newTVar :: a -> STM (TVar a) #

Create a new TVar holding a value supplied

readTVar :: TVar a -> STM a #

Return the current value stored in a TVar.

writeTVar :: TVar a -> a -> STM () #

Write the supplied value into a TVar.