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

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Moduleconcurrency-1.11.0.3Haskell2010

Control.Concurrent.Classy.STM.TQueue

A TQueue is like a TChan, with two important differences:

  • it has faster throughput than both TChan and Chan (although the costs are amortised, so the cost of individual operations can vary a lot).

  • it does not provide equivalents of the dupTChan and cloneTChan operations.

The implementation is based on the traditional purely-functional queue representation that uses two lists to obtain amortised O(1) enqueue and dequeue operations.

Deviations: TQueue as defined here does not have an Eq instance, this is because the MonadSTM TVar type does not have an Eq constraint. Furthermore, the newTQueueIO function is not provided.

  • 1 type
  • 9 values

TQueue

10 declarations
datadata TQueue (stm :: Type -> Type) a
#

TQueue is an abstract type representing an unbounded FIFO channel.

valuepeekTQueue :: MonadSTM stm => TQueue stm a -> stm a
#

Get the next value from the TQueue without removing it, retrying if the channel is empty.

valueunGetTQueue :: MonadSTM stm => TQueue stm a -> a -> stm ()
#

Put a data item back onto a channel, where it will be the next item read.