Chan package:base
Unbounded channels.
The channels are implemented with
MVars and therefore inherit
all the caveats that apply to
MVars (possibility of races,
deadlocks etc). The
stm (software transactional memory)
library has a more robust implementation of channels called
TChans.
Chan is an abstract type representing an unbounded FIFO
channel.
Duplicate a
Chan: 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.
(Note that a duplicated channel is not equal to its original. So:
fmap (c /=) $ dupChan c returns
True for all
c.)
Return a lazy list representing the contents of the supplied
Chan, much like
hGetContents.
Build and return a new instance of
Chan.
Read the next value from the
Chan. Blocks when the channel is
empty. Since the read end of a channel is an
MVar, this
operation inherits fairness guarantees of
MVars (e.g. threads
blocked in this operation are woken up in FIFO order).
Throws
BlockedIndefinitelyOnMVar when the channel is empty and
no other thread holds a reference to the channel.
Write an entire list of items to a
Chan.
How to collect a backtrace when an exception is thrown.
The atomic exchange operation. Atomically exchanges the value at the
first address with the Addr# given as second argument. Implies a read
barrier.
Warning: this can fail with an unchecked exception.
The atomic exchange operation. Atomically exchanges the value at the
address with the given value. Returns the old value. Implies a read
barrier.
Warning: this can fail with an unchecked exception.
Given an array, and offset in machine words, and a value to AND,
atomically AND the value into the element. Returns the value of the
element before the operation. Implies a full memory barrier.
Warning: this can fail with an unchecked exception.
Given an address, and a value to AND, atomically AND the value into
the element. Returns the value of the element before the operation.
Implies a full memory barrier.
Warning: this can fail with an unchecked exception.
Catch any
Exception type in the
IO monad.
Note that this function is
strict in the action. That is,
catchAny undefined b == _|_. See for details.
If you rethrow an exception, you should reuse the supplied
ExceptionContext.