TMChan is an abstract type representing a closeable FIFO
channel.
Modulestm-chans-3.0.0.9Haskell2010
Control.Concurrent.STM.TMChan
A version of Control.Concurrent.STM.TChan where the queue is
closeable. This is similar to a TChan (Maybe a) with a
monotonicity guarantee that once there's a Nothing there will
always be Nothing.
- 1 type
- 14 values
- Packagestm-chans-3.0.0.9
- Exports15
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceTMChan.hs
The TMChan type
1 declarationCreating TMChans
Build and returns a new instance of TMChan.
IO version of newTMChan. This is useful for creating
top-level TMChans using unsafePerformIO,
because using atomically inside
unsafePerformIO isn't possible.
Duplicate a TMChan: the duplicate channel begins empty, but
data written to either channel from then on will be available
from both, and closing one copy will close them all. Hence this
creates a kind of broadcast channel, where data written by anyone
is seen by everyone else.
Like newBroadcastTChan.
Since: 2.1.0
IO version of newBroadcastTMChan.
Since: 2.1.0
Reading from TMChans
Read the next value from the TMChan, retrying if the channel
is empty (and not closed). We return Nothing immediately if
the channel is closed and empty.
A version of readTMChan which does not retry. Instead it
returns Just Nothing if the channel is open but no value is
available; it still returns Nothing if the channel is closed
and empty.
Get the next value from the TMChan without removing it,
retrying if the channel is empty.
A version of peekTMChan which does not retry. Instead it
returns Just Nothing if the channel is open but no value is
available; it still returns Nothing if the channel is closed
and empty.
Writing to TMChans
Write a value to a TMChan. If the channel is closed then the
value is silently discarded. Use isClosedTMChan to determine
if the channel is closed before writing, as needed.
Put a data item back onto a channel, where it will be the next item read. If the channel is closed then the value is silently discarded; you can use peekTMChan to circumvent this in certain circumstances.
Closing TMChans
Closes the TMChan, preventing any further writes.
Predicates
Returns True if the supplied TMChan has been closed.
Returns True if the supplied TMChan is empty.