chp-1.0.2: An implementation of concurrency ideas from Communicating Sequential ProcessesSource codeContentsIndex
runParallel :: [CHP a] -> CHP [a]
runParallel_ :: [CHP a] -> CHP ()
(<||>) :: CHP a -> CHP b -> CHP (a, b)
data (Monad m, MonadCHP m) => ForkingT m a
forking :: MonadCHP m => ForkingT m a -> m a
fork :: MonadCHP m => CHP () -> ForkingT m ()
runParallel :: [CHP a] -> CHP [a]Source

This type-class supports parallel composition of processes. You may use the runParallel function to run a list of processes, or the <||> operator to run just a pair of processes.

In each case, the composition waits for all processes to finish, either successfully or with poison. At the end of this, if any process exited with poison, the composition will rethrow this poison. If all the processes completed successfully, the results will be returned. If you want to ignore poison from the sub-processes, use an empty poison handler and onPoisonTrap with each branch.

Runs the given list of processes in parallel, and then returns a list of the results, in the same order as the processes given. Will only return when all the inner processes have completed.

runParallel_ :: [CHP a] -> CHP ()Source
Runs all the given processes in parallel and discards any output. Does not return until all the processes have completed. runParallel_ ps is effectively equivalent to runParallel ps >> return ().
(<||>) :: CHP a -> CHP b -> CHP (a, b)Source
A useful operator for performing a two process equivalent of runParallel that gives the return values back as a pair rather than a list. This also allows the values to have different types
data (Monad m, MonadCHP m) => ForkingT m a Source
A monad transformer used for introducing forking blocks.
show/hide Instances
forking :: MonadCHP m => ForkingT m a -> m aSource
Executes a forking block. Processes may be forked off inside (using the fork function). When the block completes, it waits for all the forked off processes to complete before returning the output, as long as none of the processes terminated with uncaught poison. If they did, the poison is propagated (rethrown).
fork :: MonadCHP m => CHP () -> ForkingT m ()Source
Forks off the given process. The process then runs in parallel with this code, until the end of the forking block, when all forked-off processes are waited for. At that point, once all of the processes have finished, if any of them threw poison it is propagated.
Produced by Haddock version 2.3.0