Portability | non-portable (CPP, STM, DeriveDataTypeable) |
---|---|
Stability | provisional |
Maintainer | wren@community.haskell.org |
Safe Haskell | Trustworthy |
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
- data TBQueue a
- newTBQueue :: Int -> STM (TBQueue a)
- newTBQueueIO :: Int -> IO (TBQueue a)
- readTBQueue :: TBQueue a -> STM a
- tryReadTBQueue :: TBQueue a -> STM (Maybe a)
- peekTBQueue :: TBQueue a -> STM a
- tryPeekTBQueue :: TBQueue a -> STM (Maybe a)
- writeTBQueue :: TBQueue a -> a -> STM ()
- unGetTBQueue :: TBQueue a -> a -> STM ()
- isEmptyTBQueue :: TBQueue a -> STM Bool
The TBQueue type
Creating TBQueues
Build and returns a new instance of TBQueue
newTBQueueIO :: Int -> IO (TBQueue a)
IO
version of newTBQueue
. This is useful for creating top-level
TBQueue
s 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.