ConcurrentUtils-0.4.5.0: Concurrent utilities

Safe HaskellTrustworthy
LanguageHaskell98

Control.CUtils.FChan

Description

Functional channels | A channel data type which allows consumers to hold references to different points in a stream at the same time. Elements of a channel are kept alive only so long as there are references pointing before those elements; producers on a channel are kept alive only so long as there are consumers.

Synopsis

Documentation

data Chan t Source #

listToChan :: [t] -> Chan t Source #

Construct a channel from a list.

takeChan :: Chan t -> IO (t, Chan t) Source #

Take the first element from a channel, and a channel representing the remainder of the output.

tryTakeChan :: Chan t -> IO (Maybe (t, Chan t)) Source #

newChan :: IO (t -> IO (), Chan t) Source #

Create a new channel. The first return value is a function that can be used to add values to the channel. The second return value is the channel itself.

makeConsumer :: Chan b -> IO (IO b, IO (Chan b)) Source #

The first return value is a procedure that returns values from the channel successively, starting from the position of the parameter channel. The second thunk can be used to retrieve the position of the channel after all the reads made using the first thunk.

dupChan :: Chan a -> IO (Chan a) Source #

Create a channel which is initially empty, but accumulates new elements.