orc- Orchestration-style co-ordination EDSL

StabilityPortability : concurrency, unsafeIntereaveIO
MaintainerJohn Launchbury <john@galois.com>
Safe HaskellNone



Hierarchical concurrent threads, which kill all of their descendants when they are killed.



data HIO a Source

The HIO monad is simply the IO monad augmented with an environment that tracks the current thread Group. This permits us to keep track of forked threads and kill them en mass when an ancestor is killed. The HIO monad is an instance of MonadIO, so arbitrary IO actions may be embedded in it; however, the user is advised that any action may be summarily killed, and thus it is of extra importance that appropriate bracketing functions are used.


Monad HIO 
Functor HIO 
Applicative HIO 
HasFork HIO 

The thread-registry environment is a hierarchical structure of local thread neighborhoods.

runHIO :: HIO b -> IO ()Source

Runs a HIO operation inside a new thread group that has no parent, and blocks until all subthreads of the operation are done executing. If countingThreads is True, it then prints some debugging information about the threads run (XXX: this seems suboptimal.)

newPrimGroup :: IO GroupSource

Creates a new, empty thread group.

newGroup :: HIO GroupSource

Creates a new thread group and registers the current environment's thread group in it. If the current group is closed, immediately terminates execution of the current thread.

local :: Group -> HIO a -> HIO aSource

Explicitly sets the current Group environment for a HIO monad.

close :: Group -> HIO ()Source

Kill all threads which are descendants of a Group and closes the group, disallowing new threads or groups to be added to the group. Doesn't do anything if the group is already closed.

type Group = (TVar Int, TVar Inhabitants)Source

A thread Group keeps tracks of its inhabitants, which may be threads or other Groups.

finished :: Group -> HIO ()Source

Blocks until the Group w is finished executing.