Copyright | (c) 2008-2010 Galois, Inc. |
---|---|
License | BSD3 |
Maintainer | John Launchbury <john@galois.com> |
Stability | Portability : concurrency, unsafeIntereaveIO |
Safe Haskell | None |
Language | Haskell2010 |
Hierarchical concurrent threads, which kill all of their descendants when they are killed.
Documentation
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.
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 Group Source
Creates a new, empty thread group.
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.
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.