buildbox- Rehackable components for writing buildbots and test harnesses.



A gang consisting of a fixed number of threads that can run actions in parallel. Good for constructing parallel test frameworks.



data Gang Source

Abstract gang of threads.

data GangState Source



Gang is running and starting new actions.


Gang may be running already started actions, but no new ones are being started.


Gang is waiting for currently running actions to finish, but not starting new ones.


Gang is finished, all the actions have completed.


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. Gang state changes to GangRunning.

flushGang :: Gang -> IO ()Source

Block until already started actions have completed, but don't start any more. Gang state changes to GangFlushing.

killGang :: Gang -> IO ()Source

Kill all the threads in a gang. Gang stage changes to GangKilled.

getGangState :: Gang -> IO GangStateSource

Get the state of a gang.

waitForGangState :: Gang -> GangState -> IO ()Source

Block until the gang is in the given state.