HORIZON HASKELLDocslts/ghc-10.0.x04404a62026-10-19Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 04404a6 · 2026-10-19

Modulestm-2.5.3.1Haskell2010

Control.Concurrent.STM.TVar

Contents
  1. TVars
Synopsis
  • Packagestm-2.5.3.1
  • Exports12
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceSTM.hs

TVars

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.

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.