HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulererebase-1.21.2Haskell2010

Control.Concurrent.STM.TVar

  • 1 type
  • 11 values
datadata TVar a
#

Shared memory locations that support atomic memory transactions.

Instances4Eq, HasGetter, HasSetter, HasUpdate
  • Eq (TVar a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • HasGetter (TVar a) aDefined in StateVar-1.2.2 · Data.StateVar
  • HasSetter (TVar a) aDefined in StateVar-1.2.2 · Data.StateVar
  • HasUpdate (TVar a) a aDefined in StateVar-1.2.2 · Data.StateVar
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.

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.