Control.Concurrent.STM.TVar
| Copyright | (c) The University of Glasgow 2004 |
|---|---|
| License | BSD-style (see the file libraries/base/LICENSE) |
| Maintainer | [email protected] |
| Stability | experimental |
| Portability | non-portable (requires STM) |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Contents
Description
TVars
Shared memory locations that support atomic memory transactions.
Instances
newTVar :: a -> STM (TVar a) Source
Create a new TVar holding a value supplied
newTVarIO :: a -> IO (TVar a) Source
IO version of newTVar. This is useful for creating top-level TVars using unsafePerformIO, because using atomically inside unsafePerformIO isn't possible.
readTVar :: TVar a -> STM a Source
Return the current value stored in a TVar.
readTVarIO :: TVar a -> IO a Source
Return the current value stored in a TVar. This is equivalent to
readTVarIO = atomically . readTVar
but works much faster, because it doesn't perform a complete transaction, it just reads the current value of the TVar.
writeTVar :: TVar a -> a -> STM () Source
Write the supplied value into a TVar.
modifyTVar :: TVar a -> (a -> a) -> STM () Source
Mutate the contents of a TVar. N.B., this version is non-strict.
Since: stm-2.3
modifyTVar' :: TVar a -> (a -> a) -> STM () Source
Strict version of modifyTVar.
Since: stm-2.3
stateTVar :: TVar s -> (s -> (a, s)) -> STM a Source
Like modifyTVar' but the function is a simple state transition that can return a side value which is passed on as the result of the STM.
Since: stm-2.5.0
swapTVar :: TVar a -> a -> STM a Source
Swap the contents of a TVar for a new value.
Since: stm-2.3
registerDelay :: Int -> IO (TVar Bool) Source
Switch the value of returned TVar from initial value False to True after a given number of microseconds. The caveats associated with threadDelay also apply.
mkWeakTVar :: TVar a -> IO () -> IO (Weak (TVar a)) Source
Make a Weak pointer to a TVar, using the second argument as a finalizer to run when TVar is garbage-collected
Since: stm-2.4.3
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.10.2/docs/html/libraries/stm-2.5.0.0/Control-Concurrent-STM-TVar.html