chp-plus-1.0.0: A set of high-level concurrency utilities built on Communicating Haskell Processes

Control.Concurrent.CHP.Buffers

Description

Various processes that act like buffers. Poisoning either end of a buffer process is immediately passed on to the other side, in contrast to C++CSP2 and JCSP.

Synopsis

Documentation

fifoBuffer :: forall a. Int -> Chanin a -> Chanout a -> CHP ()Source

Acts like a limited capacity FIFO buffer of the given size. When it is full it accepts no input, and when it is empty it offers no output.

infiniteBuffer :: forall a. Chanin a -> Chanout a -> CHP ()Source

Acts like a FIFO buffer with unlimited capacity. Use with caution; make sure you do not let the buffer grow so large that it eats up all your memory. When it is empty, it offers no output. It always accepts input.

accumulatingInfiniteBuffer :: forall a. Chanin a -> Chanout [a] -> CHP ()Source

Acts like a FIFO buffer with unlimited capacity, but accumulates sequential inputs into a list which it offers in a single output. Use with caution; make sure you do not let the buffer grow so large that it eats up all your memory. When it is empty, it offers the empty list. It always accepts input. Once it has sent out a value (or values) it removes them from its internal storage.

overflowingBuffer :: forall a. Int -> Chanin a -> Chanout a -> CHP ()Source

Acts like a FIFO buffer of limited capacity, except that when it is full, it always accepts input and discards it. When it is empty, it does not offer output.

overwritingBuffer :: forall a. Int -> Chanin a -> Chanout a -> CHP ()Source

Acts like a FIFO buffer of limited capacity, except that when it is full, it always accepts input and pushes out the oldest item in the buffer. When it is empty, it does not offer output.