chp-2.2.0.1: An implementation of concurrency ideas from Communicating Sequential Processes

Safe HaskellSafe-Inferred

Control.Concurrent.CHP.Channels.Ends

Description

Channels in CHP must be used via their ends. It is generally these ends that you pass around to processes that want to communicate on the channel -- thus it is possible to see from the type ('Chanin'\/'Chanout') whether the process will use it for reading or writing. The channel-ends are named from the perspective of processes: a Chanin is a channel-end that a process may input values from, whereas a Chanout is a channel-end that a process may output values to.

Synopsis

Documentation

data Chanin a Source

A reading channel-end type.

See reader to obtain one, and ReadableChannel for how to use one.

Eq instance added in version 1.1.1

data Chanout a Source

A writing channel-end type.

See writer to obtain one, and WritableChannel for how to use one.

Eq instance added in version 1.1.1

data Shared c a Source

A wrapper (usually around a channel-end) indicating that the inner item is shared. Use the claim function to use this type.

reader :: Chan r w a -> r aSource

Gets the reading end of a channel from its Chan type.

writer :: Chan r w a -> w aSource

Gets the writing end of a channel from its Chan type.

readers :: [Chan r w a] -> [r a]Source

Gets all the reading ends of a list of channels. A shorthand for map reader.

writers :: [Chan r w a] -> [w a]Source

Gets all the writing ends of a list of channels. A shorthand for map writer.

claim :: Shared c a -> (c a -> CHP b) -> CHP bSource

Claims the given channel-end, executes the given block, then releases the channel-end and returns the output value. If poison or an IO exception is thrown inside the block, the channel is released and the poison/exception re-thrown.