stm-chans-2.1.0: Additional types of channels for STM.

Portabilitynon-portable (CPP, STM, DeriveDataTypeable)
Stabilityprovisional
Maintainerwren@community.haskell.org
Safe HaskellTrustworthy

Control.Concurrent.STM.TQueue.Compat

Contents

Description

Deprecated: stm-chans >= 2.1 requires stm >= 2.4; so this module no longer does anything useful.

Compatibility layer for older versions of the stm library. Namely, we copy Control.Concurrent.STM.TQueue module which stm < 2.4.0 lacks. This module uses Cabal-style CPP macros in order to use the package versions when available.

Since: 2.0.0; Deprecated: 2.1.0 (will be removed in 3.0)

Synopsis

The TQueue type

data TQueue a

TQueue is an abstract type representing an unbounded FIFO channel.

Instances

Creating TQueues

newTQueue :: STM (TQueue a)

Build and returns a new instance of TQueue

newTQueueIO :: IO (TQueue a)

IO version of newTQueue. This is useful for creating top-level TQueues using unsafePerformIO, because using atomically inside unsafePerformIO isn't possible.

Reading from TQueues

readTQueue :: TQueue a -> STM a

Read the next value from the TQueue.

tryReadTQueue :: TQueue a -> STM (Maybe a)

A version of readTQueue which does not retry. Instead it returns Nothing if no value is available.

peekTQueue :: TQueue a -> STM a

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

tryPeekTQueue :: TQueue a -> STM (Maybe a)

A version of peekTQueue which does not retry. Instead it returns Nothing if no value is available.

Writing to TQueues

writeTQueue :: TQueue a -> a -> STM ()

Write a value to a TQueue.

unGetTQueue :: TQueue a -> a -> STM ()

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

Predicates

isEmptyTQueue :: TQueue a -> STM Bool

Returns True if the supplied TQueue is empty.