HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulestm-chans-3.0.0.9Haskell2010

Control.Concurrent.STM.TMQueue

A version of Control.Concurrent.STM.TQueue where the queue is closeable. This is similar to a TQueue (Maybe a) with a monotonicity guarantee that once there's a Nothing there will always be Nothing.

Since: 2.0.0

  • 1 type
  • 11 values
  • Packagestm-chans-3.0.0.9
  • Exports12
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceTMQueue.hs

The TMQueue type

1 declaration
datadata TMQueue a
#

TMQueue is an abstract type representing a closeable FIFO queue.

Creating TMQueues

Reading from TMQueues

valuereadTMQueue :: TMQueue a -> STM (Maybe a)
#

Read the next value from the TMQueue, retrying if the queue is empty (and not closed). We return Nothing immediately if the queue is closed and empty.

valuetryReadTMQueue :: TMQueue a -> STM (Maybe (Maybe a))
#

A version of readTMQueue which does not retry. Instead it returns Just Nothing if the queue is open but no value is available; it still returns Nothing if the queue is closed and empty.

valuepeekTMQueue :: TMQueue a -> STM (Maybe a)
#

Get the next value from the TMQueue without removing it, retrying if the queue is empty.

valuetryPeekTMQueue :: TMQueue a -> STM (Maybe (Maybe a))
#

A version of peekTMQueue which does not retry. Instead it returns Just Nothing if the queue is open but no value is available; it still returns Nothing if the queue is closed and empty.

Writing to TMQueues

valuewriteTMQueue :: TMQueue a -> a -> STM ()
#

Write a value to a TMQueue. If the queue is closed then the value is silently discarded. Use isClosedTMQueue to determine if the queue is closed before writing, as needed.

valueunGetTMQueue :: TMQueue a -> a -> STM ()
#

Put a data item back onto a queue, where it will be the next item read. If the queue is closed then the value is silently discarded; you can use peekTMQueue to circumvent this in certain circumstances.

Closing TMQueues

Predicates