Safe Haskell | Safe |
---|---|
Language | Haskell98 |
A gang consisting of a fixed number of threads that can run actions in parallel. Good for constructing parallel test frameworks.
Documentation
GangRunning | Gang is running and starting new actions. |
GangPaused | Gang may be running already started actions, but no new ones are being started. |
GangFlushing | Gang is waiting for currently running actions to finish, but not starting new ones. |
GangFinished | Gang is finished, all the actions have completed. |
GangKilled | Gang was killed, all the threads are dead (or dying). |
:: Int | Number of worker threads in the gang / maximum number of actions to execute concurrenty. |
-> [IO ()] | Actions to run. They are started in-order, but may finish out-of-order depending on the run time of the individual action. |
-> IO Gang |
Fork a new gang to run the given actions.
This function returns immediately, with the gang executing in the background.
Gang state starts as GangRunning
then transitions to GangFinished
.
To block until all the actions are finished use joinGang
.
joinGang :: Gang -> IO () Source #
Block until all actions have finished executing, or the gang is killed.
pauseGang :: Gang -> IO () Source #
Pause a gang. Actions that have already been started continue to run,
but no more will be started until a resumeGang
command is issued.
Gang state changes to GangPaused
.
resumeGang :: Gang -> IO () Source #
Resume a paused gang, which allows it to continue starting new actions.
If the gang was paused it now changes to GangRunning
,
otherwise nothing happens.