| |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
Description | |||||||||||||||||||||||||||
Synchronising variables | |||||||||||||||||||||||||||
Synopsis | |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
MVars | |||||||||||||||||||||||||||
data MVar a | |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
newEmptyMVar :: IO (MVar a) | |||||||||||||||||||||||||||
Create an MVar which is initially empty. | |||||||||||||||||||||||||||
newMVar :: a -> IO (MVar a) | |||||||||||||||||||||||||||
Create an MVar which contains the supplied value. | |||||||||||||||||||||||||||
takeMVar :: MVar a -> IO a | |||||||||||||||||||||||||||
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. If several threads are competing to take the same MVar, one is chosen to continue at random when the MVar becomes full. | |||||||||||||||||||||||||||
putMVar :: MVar a -> a -> IO () | |||||||||||||||||||||||||||
Put a value into an MVar. If the MVar is currently full, putMVar will wait until it becomes empty. If several threads are competing to fill the same MVar, one is chosen to continue at random with the MVar becomes empty. | |||||||||||||||||||||||||||
readMVar :: MVar a -> IO a | |||||||||||||||||||||||||||
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 | |||||||||||||||||||||||||||
Swap the contents of an MVar for a new value. | |||||||||||||||||||||||||||
tryTakeMVar :: MVar a -> IO (Maybe a) | |||||||||||||||||||||||||||
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. | |||||||||||||||||||||||||||
tryPutMVar :: MVar a -> a -> IO Bool | |||||||||||||||||||||||||||
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. | |||||||||||||||||||||||||||
isEmptyMVar :: MVar a -> IO Bool | |||||||||||||||||||||||||||
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. | |||||||||||||||||||||||||||
withMVar :: MVar a -> (a -> IO b) -> IO b | |||||||||||||||||||||||||||
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). | |||||||||||||||||||||||||||
modifyMVar_ :: MVar a -> (a -> IO a) -> IO () | |||||||||||||||||||||||||||
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. | |||||||||||||||||||||||||||
modifyMVar :: MVar a -> (a -> IO (a, b)) -> IO b | |||||||||||||||||||||||||||
A slight variation on modifyMVar_ that allows a value to be returned (b) in addition to the modified value of the MVar. | |||||||||||||||||||||||||||
addMVarFinalizer :: MVar a -> IO () -> IO () | |||||||||||||||||||||||||||
Add a finalizer to an MVar (GHC only). See Foreign.ForeignPtr and System.Mem.Weak for more about finalizers. | |||||||||||||||||||||||||||
Produced by Haddock version 0.6 |