Copyright | (c) 2016 Michael Walker |
---|---|
License | MIT |
Maintainer | Michael Walker <mike@barrucadu.co.uk> |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Transactional channels
Deviations: TChan
as defined here does not have an Eq
instance, this is because the MonadSTM
TVar
type does not have
an Eq
constraint. Furthermore, the newTChanIO
and
newBroadcastTChanIO
functions are not provided.
Synopsis
- data TChan stm a
- newTChan :: MonadSTM stm => stm (TChan stm a)
- newBroadcastTChan :: MonadSTM stm => stm (TChan stm a)
- dupTChan :: MonadSTM stm => TChan stm a -> stm (TChan stm a)
- cloneTChan :: MonadSTM stm => TChan stm a -> stm (TChan stm a)
- readTChan :: MonadSTM stm => TChan stm a -> stm a
- tryReadTChan :: MonadSTM stm => TChan stm a -> stm (Maybe a)
- peekTChan :: MonadSTM stm => TChan stm a -> stm a
- tryPeekTChan :: MonadSTM stm => TChan stm a -> stm (Maybe a)
- writeTChan :: MonadSTM stm => TChan stm a -> a -> stm ()
- unGetTChan :: MonadSTM stm => TChan stm a -> a -> stm ()
- isEmptyTChan :: MonadSTM stm => TChan stm a -> stm Bool
TChans
TChan
is an abstract type representing an unbounded FIFO
channel.
Since: 1.0.0.0
Construction
newTChan :: MonadSTM stm => stm (TChan stm a) Source #
Build and return a new instance of TChan
Since: 1.0.0.0
newBroadcastTChan :: MonadSTM stm => stm (TChan stm a) Source #
dupTChan :: MonadSTM stm => TChan stm a -> stm (TChan stm a) Source #
Duplicate a TChan
: the duplicate channel begins empty, but data written to
either channel from then on will be available from both. Hence
this creates a kind of broadcast channel, where data written by
anyone is seen by everyone else.
Since: 1.0.0.0
Reading and writing
readTChan :: MonadSTM stm => TChan stm a -> stm a Source #
Read the next value from the TChan
.
Since: 1.0.0.0
tryReadTChan :: MonadSTM stm => TChan stm a -> stm (Maybe a) Source #
A version of readTChan
which does not retry. Instead it
returns Nothing
if no value is available.
Since: 1.0.0.0
peekTChan :: MonadSTM stm => TChan stm a -> stm a Source #
Get the next value from the TChan
without removing it,
retrying if the channel is empty.
Since: 1.0.0.0
tryPeekTChan :: MonadSTM stm => TChan stm a -> stm (Maybe a) Source #
A version of peekTChan
which does not retry. Instead it
returns Nothing
if no value is available.
Since: 1.0.0.0
writeTChan :: MonadSTM stm => TChan stm a -> a -> stm () Source #
Write a value to a TChan
.
Since: 1.0.0.0
unGetTChan :: MonadSTM stm => TChan stm a -> a -> stm () Source #
Put a data item back onto a channel, where it will be the next item read.
Since: 1.0.0.0