Control.Concurrent.STM.TVar

stm-2.5.3.1: Software Transactional Memory

Copyright | (c) The University of Glasgow 2004
License | BSD-style (see the file libraries/base/LICENSE)
Maintainer | libraries@haskell.org
Stability | experimental
Portability | non-portable (requires STM)
Safe Haskell | Trustworthy
Language | Haskell2010

Control.Concurrent.STM.TVar

Contents

- TVars

Description

Synopsis

- data TVar a
- newTVar :: a -> STM (TVar a)
- newTVarIO :: a -> IO (TVar a)
- readTVar :: TVar a -> STM a
- readTVarIO :: TVar a -> IO a
- writeTVar :: TVar a -> a -> STM ()
- modifyTVar :: TVar a -> (a -> a) -> STM ()
- modifyTVar' :: TVar a -> (a -> a) -> STM ()
- stateTVar :: TVar s -> (s -> (a, s)) -> STM a
- swapTVar :: TVar a -> a -> STM a
- registerDelay :: Int -> IO (TVar Bool)
- mkWeakTVar :: TVar a -> IO () -> IO (Weak (TVar a))

# TVars

data TVar a #

#### Instances

Instances details

Eq (TVar a) # |
Instance details Defined in GHC.Internal.Conc.Sync Methods (==) :: TVar a -> TVar a -> Bool # (/=) :: TVar a -> TVar a -> Bool #

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

newTVarIO :: a -> IO (TVar a) #

readTVar :: TVar a -> STM a #

readTVarIO :: TVar a -> IO a #

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

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) #

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