HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulestm-chans-3.0.0.11Haskell2010

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

Contents
  1. The TMQueue type
  2. Creating TMQueues
  3. Reading from TMQueues
  4. Writing to TMQueues
  5. Closing TMQueues
  6. Predicates
Synopsis

The TMQueue type

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.

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