Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module exposes a Supervisor
construct, which can be used to safely
spawn threads while guaranteeing that:
- When the supervisor is killed, all of the threads it supervises will be killed.
- Child threads can terminate in any order, and memory usage will always be proportional to the number of *live* supervised threads.
Synopsis
- data Supervisor
- withSupervisor :: (Supervisor -> IO a) -> IO a
- supervise :: Supervisor -> IO () -> IO ()
- superviseSTM :: Supervisor -> IO () -> STM ()
Documentation
data Supervisor Source #
A handle for a supervisor, which montiors a pool of threads.
withSupervisor :: (Supervisor -> IO a) -> IO a Source #
Run an IO action with access to a supervisor. Threads spawned using the supervisor will be killed when the action returns.
supervise :: Supervisor -> IO () -> IO () Source #
Launch the IO action in a thread, monitored by the Supervisor
. If the
supervisor receives an exception, the exception will also be raised in the
child thread.
superviseSTM :: Supervisor -> IO () -> STM () Source #