Portability | non-portable (requires STM) |
---|---|
Stability | experimental |
Maintainer | libraries@haskell.org |
Safe Haskell | Safe-Infered |
TVar: Transactional variables
TVars
data TVar a
Shared memory locations that support atomic memory transactions.
IO
version of newTVar
. This is useful for creating top-level
TVar
s using unsafePerformIO
, because using
atomically
inside unsafePerformIO
isn't
possible.
readTVarIO :: TVar a -> IO a
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
.
registerDelay :: Int -> IO (TVar Bool)
Set the value of returned TVar to True after a given number of microseconds. The caveats associated with threadDelay also apply.