Portability | non-portable (requires Futures) |
---|---|
Stability | experimental |
Maintainer | willig@ki.informatik.uni-frankfurt.de |
This module implements a channel synchronisation primitive using buffers that block on futures. A channel is a linked list of buffers. It has a read-end at one side and a write-end at the other. Elements put into the channel can be read out in a first in, first out order. A read and a write operation can be executed in parallel by several threads. A channel has no capacity bounding.
The module contains similar functions as Control.Concurrent.Futures.Chan
.
Warning: All operations on channels should only be used within the global wrapper function
Futures.withFuturesDo
!
Documentation
A channel consists of a read-end buffer and a write-end buffer. The Itemtype is required to link the buffers in the channel.
writeChan :: Chan a -> a -> IO ()Source
Writes one value to a channel. A writeChan
never blocks, since channels have
no bounding limiters.
readChan :: Chan a -> IO aSource
Reads out an item from the read-head of the channel. It blocks on a empty channel.
writeChanContents :: Chan a -> [a] -> IO ()Source
Implements the same behaviour as writeChanContents from the module Control.Concurrent.Chan.
getChanContents :: Chan a -> IO [a]Source
Implements the same behaviour as getChanContents from the module Control.Concurrent.Chan. It reads permanently from the channel.