MVar

module Control.Concurrent.MVar
base Control.Concurrent.MVar
Synchronising variables
data MVar a
base Control.Concurrent.MVar
An MVar (pronounced "em-var") is a synchronising variable, used for communication between concurrent threads. It can be thought of as a a box, which may be empty or full.
addMVarFinalizer :: MVar a -> IO () -> IO ()
base Control.Concurrent.MVar
Add a finalizer to an MVar (GHC only). See Foreign.ForeignPtr and System.Mem.Weak for more about finalizers.
BlockedIndefinitelyOnMVar :: BlockedIndefinitelyOnMVar
base Control.Exception.Base, base Control.Exception
data BlockedIndefinitelyOnMVar
base Control.Exception.Base, base Control.Exception
The thread is blocked on an MVar, but there are no other references to the MVar so it can't ever continue.
BlockedOnDeadMVar :: Exception
base Control.OldException
The current thread was executing a call to Control.Concurrent.MVar.takeMVar that could never return, because there are no other references to this MVar.
isEmptyMVar :: MVar a -> IO Bool
base Control.Concurrent.MVar
Check whether a given MVar is empty. Notice that the boolean value returned is just a snapshot of the state of the MVar. By the time you get to react on its result, the MVar may have been filled (or emptied) - so be extremely careful when using this operation. Use tryTakeMVar instead if possible.
modifyMVar :: MVar a -> (a -> IO (a, b)) -> IO b
base Control.Concurrent.MVar
A slight variation on modifyMVar_ that allows a value to be returned (b) in addition to the modified value of the MVar.
modifyMVar_ :: MVar a -> (a -> IO a) -> IO ()
base Control.Concurrent.MVar
A safe wrapper for modifying the contents of an MVar. Like withMVar, modifyMVar will replace the original contents of the MVar if an exception is raised during the operation.
newEmptyMVar :: IO (MVar a)
base Control.Concurrent.MVar
Create an MVar which is initially empty.
newMVar :: a -> IO (MVar a)
base Control.Concurrent.MVar
Create an MVar which contains the supplied value.
putMVar :: MVar a -> a -> IO ()
base Control.Concurrent.MVar
Put a value into an MVar. If the MVar is currently full, putMVar will wait until it becomes empty. There are two further important properties of putMVar: * putMVar is single-wakeup. That is, if there are multiple threads blocked in putMVar, and the MVar becomes empty, only one thread will be woken up. The runtime guarantees that the woken thread completes its putMVar operation. * When multiple threads are blocked on an MVar, they are woken up in FIFO order. This is useful for providing fairness properties of abstractions built using MVars.
readMVar :: MVar a -> IO a
base Control.Concurrent.MVar
This is a combination of takeMVar and putMVar; ie. it takes the value from the MVar, puts it back, and also returns it.
swapMVar :: MVar a -> a -> IO a
base Control.Concurrent.MVar
Take a value from an MVar, put a new value into the MVar and return the value taken. Note that there is a race condition whereby another process can put something in the MVar after the take happens but before the put does.
takeMVar :: MVar a -> IO a
base Control.Concurrent.MVar
Return the contents of the MVar. If the MVar is currently empty, takeMVar will wait until it is full. After a takeMVar, the MVar is left empty. There are two further important properties of takeMVar: * takeMVar is single-wakeup. That is, if there are multiple threads blocked in takeMVar, and the MVar becomes full, only one thread will be woken up. The runtime guarantees that the woken thread completes its takeMVar operation. * When multiple threads are blocked on an MVar, they are woken up in FIFO order. This is useful for providing fairness properties of abstractions built using MVars.
tryPutMVar :: MVar a -> a -> IO Bool
base Control.Concurrent.MVar
A non-blocking version of putMVar. The tryPutMVar function attempts to put the value a into the MVar, returning True if it was successful, or False otherwise.
tryTakeMVar :: MVar a -> IO (Maybe a)
base Control.Concurrent.MVar
A non-blocking version of takeMVar. The tryTakeMVar function returns immediately, with Nothing if the MVar was empty, or Just a if the MVar was full with contents a. After tryTakeMVar, the MVar is left empty.
withMVar :: MVar a -> (a -> IO b) -> IO b
base Control.Concurrent.MVar
withMVar is a safe wrapper for operating on the contents of an MVar. This operation is exception-safe: it will replace the original contents of the MVar if an exception is raised (see Control.Exception).
BlockedOnMVar :: BlockReason
base GHC.Conc.Sync, base GHC.Conc
blocked on on MVar
module Control.Concurrent.STM.TMVar
stm Control.Concurrent.STM.TMVar
TMVar: Transactional MVars, for use in the STM monad (GHC only)
package expiring-mvar
package
expiring-mvar provides the type ExpiringMVar. ExpiringMVar is a container for a single value. When creating an ExpiringMVar, a thread is spawned which deletes the value held in the ExpiringMVar after a given period of time. The timer can be reset, cancelled, or restarted with a new time amount. Version 0.1
type FormVar = (String, String)
HTTP Network.Browser
isEmptyTMVar :: TMVar a -> STM Bool
stm Control.Concurrent.STM.TMVar
Check whether a given TMVar is empty.
modifyMVar_ :: MVar a -> (a -> IO a) -> IO ()
base GHC.Conc.Sync
newEmptyTMVar :: STM (TMVar a)
stm Control.Concurrent.STM.TMVar
Create a TMVar which is initially empty.
newEmptyTMVarIO :: IO (TMVar a)
stm Control.Concurrent.STM.TMVar
IO version of newEmptyTMVar. This is useful for creating top-level TMVars using unsafePerformIO, because using atomically inside unsafePerformIO isn't possible.
newTMVar :: a -> STM (TMVar a)
stm Control.Concurrent.STM.TMVar
Create a TMVar which contains the supplied value.
newTMVarIO :: a -> IO (TMVar a)
stm Control.Concurrent.STM.TMVar
IO version of newTMVar. This is useful for creating top-level TMVars using unsafePerformIO, because using atomically inside unsafePerformIO isn't possible.
oFFSET_StgMVar_head :: Int
base GHC.Constants
oFFSET_StgMVar_tail :: Int
base GHC.Constants
oFFSET_StgMVar_value :: Int
base GHC.Constants
oFFSET_StgMVarTSOQueue_link :: Int
base GHC.Constants
oFFSET_StgMVarTSOQueue_tso :: Int
base GHC.Constants
putTMVar :: TMVar a -> a -> STM ()
stm Control.Concurrent.STM.TMVar
Put a value into a TMVar. If the TMVar is currently full, putTMVar will retry.
readTMVar :: TMVar a -> STM a
stm Control.Concurrent.STM.TMVar
This is a combination of takeTMVar and putTMVar; ie. it takes the value from the TMVar, puts it back, and also returns it.
sIZEOF_StgMVar_NoHdr :: Int
base GHC.Constants
sIZEOF_StgMVarTSOQueue_NoHdr :: Int
base GHC.Constants
swapTMVar :: TMVar a -> a -> STM a
stm Control.Concurrent.STM.TMVar
Swap the contents of a TMVar for a new value.
takeTMVar :: TMVar a -> STM a
stm Control.Concurrent.STM.TMVar
Return the contents of the TMVar. If the TMVar is currently empty, the transaction will retry. After a takeTMVar, the TMVar is left empty.
data TMVar a
stm Control.Concurrent.STM.TMVar
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.

Show more results