HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Modulestm-2.5.3.1Haskell2010

Control.Concurrent.STM.TVar

  • 1 type
  • 11 values
  • Packagestm-2.5.3.1
  • Exports12
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceSTM.hs

TVars

12 declarations
datadata TVar a
#

Shared memory locations that support atomic memory transactions.

Instances1Eq
  • Eq (TVar a)Defined in ghc-internal-10.0.0 · GHC.Internal.STM
valuereadTVarIO :: 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.

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

Mutate the contents of a TVar. N.B., this version is non-strict.

valuestateTVar :: TVar s -> (s -> (a, s)) -> STM a
#

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.

valueregisterDelay :: Int -> IO (TVar Bool)
#

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.

Be careful not to exceed maxBound :: Int, which on 32-bit machines is only 2147483647 μs, less than 36 minutes.