| Copyright | (c) The University of Glasgow 2012 | 
|---|---|
| License | BSD-style (see the file libraries/base/LICENSE) | 
| Maintainer | libraries@haskell.org | 
| Stability | experimental | 
| Portability | non-portable (requires STM) | 
| Safe Haskell | Trustworthy | 
| Language | Haskell2010 | 
Control.Concurrent.STM.TQueue
Contents
Description
A TQueue is like a TChan, with two important differences:
- it has faster throughput than both TChanandChan(although the costs are amortised, so the cost of individual operations can vary a lot).
- it does not provide equivalents of the dupTChanandcloneTChanoperations.
The implementation is based on the traditional purely-functional queue representation that uses two lists to obtain amortised O(1) enqueue and dequeue operations.
Since: stm-2.4
Synopsis
- data TQueue a
- newTQueue :: STM (TQueue a)
- newTQueueIO :: IO (TQueue a)
- readTQueue :: TQueue a -> STM a
- tryReadTQueue :: TQueue a -> STM (Maybe a)
- flushTQueue :: TQueue a -> STM [a]
- peekTQueue :: TQueue a -> STM a
- tryPeekTQueue :: TQueue a -> STM (Maybe a)
- writeTQueue :: TQueue a -> a -> STM ()
- unGetTQueue :: TQueue a -> a -> STM ()
- isEmptyTQueue :: TQueue a -> STM Bool
TQueue
TQueue is an abstract type representing an unbounded FIFO channel.
Since: stm-2.4
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.
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.
flushTQueue :: TQueue a -> STM [a] #
Efficiently read the entire contents of a TQueue into a list. This
 function never retries.
Since: stm-2.4.5
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.
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.