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.TBQueue.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.TBQueue 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 TBQueue type

data TBQueue a

TBQueue is an abstract type representing a bounded FIFO channel.

Instances

Creating TBQueues

newTBQueue

Arguments

:: Int

maximum number of elements the queue can hold

-> STM (TBQueue a) 

Build and returns a new instance of TBQueue

newTBQueueIO :: Int -> IO (TBQueue a)

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

Reading from TBQueues

readTBQueue :: TBQueue a -> STM a

Read the next value from the TBQueue.

tryReadTBQueue :: TBQueue a -> STM (Maybe a)

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

peekTBQueue :: TBQueue a -> STM a

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

tryPeekTBQueue :: TBQueue a -> STM (Maybe a)

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

Writing to TBQueues

writeTBQueue :: TBQueue a -> a -> STM ()

Write a value to a TBQueue; blocks if the queue is full.

unGetTBQueue :: TBQueue a -> a -> STM ()

Put a data item back onto a channel, where it will be the next item read. Blocks if the queue is full.

Predicates

isEmptyTBQueue :: TBQueue a -> STM Bool

Returns True if the supplied TBQueue is empty.