Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This is a re-implementation of a module from Galois. It is part of the orc
package, which I am interested in experimenting with. I wanted to re-implement 2
out of the 3 modules in the original Orc
package, so rather than import it
only to chuck 2/3 of it just for its HIO
module I have reproduced it here.
Synopsis
- newtype HIO a = HIO {}
- runHIO :: HIO b -> IO ()
- unHIO :: HIO a -> a
- type Group = (TVar Int, TVar Inhabitants)
- newGroup :: HIO Group
- local :: Group -> HIO a -> HIO a
- close :: Group -> IO ()
- finished :: Group -> HIO ()
- register :: Entry -> Group -> IO ()
- data Entry
- data Inhabitants
- countingThreads :: Bool
- threadCount :: TVar Integer
- incrementThreadCount :: IO ()
- printThreadReport :: IO ()
Hierarchical IO
HIO
is simply IO
augmented with an environment that tracks the current
thread Group
. This permits tracking forked threads and culling them
en masse when an ancestor is killed.
Because of its MonadIO
instance arbitrary IO
actions may be embedded;
however it is advised that any action be summarily killed.
runHIO :: HIO b -> IO () Source #
Runs a HIO
computation 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.
Thread groups
newGroup :: HIO Group Source #
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 -> IO () Source #
Kills 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.
register :: Entry -> Group -> IO () Source #
Registers a thread/group entry tid
in a Group
, terminating the current
thread (suicide) if the group is closed.
Auxiliary types
data Inhabitants Source #
Profiling HIO
incrementThreadCount :: IO () Source #
printThreadReport :: IO () Source #