nqe-0.5.0: Concurrency library in the style of Erlang/OTP

Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.NQE.Supervisor

Synopsis

Documentation

data SupervisorMessage n Source #

A supervisor will start, stop and monitor processes.

data Strategy Source #

Supervisor strategies to decide what to do when a child stops.

Constructors

Notify ((Async (), Either SomeException ()) -> STM ())

run this STM action when a process stops

KillAll

kill all processes and propagate exception

IgnoreGraceful

ignore processes that stop without raising exceptions

IgnoreAll

do nothing and keep running if a process dies

supervisor :: (MonadUnliftIO m, Mailbox mbox (SupervisorMessage n), m ~ n) => Strategy -> mbox (SupervisorMessage n) -> [n ()] -> m () Source #

Run a supervisor with a given Strategy a Mailbox to control it, and a list of children to launch. The list can be empty.

addChild :: (MonadUnliftIO n, MonadIO m, Mailbox mbox (SupervisorMessage n)) => mbox (SupervisorMessage n) -> n () -> m (Async ()) Source #

Add a new child process to the supervisor. The child process will run in the supervisor context. Will return an Async for the child. This function will not block or raise an exception if the child dies.

removeChild :: (MonadUnliftIO n, MonadIO m, Mailbox mbox (SupervisorMessage n)) => mbox (SupervisorMessage n) -> Async () -> m () Source #

Stop a child process controlled by the supervisor. Must pass the child Async. Will not wait for the child to die.

stopSupervisor :: (MonadUnliftIO n, MonadIO m, Mailbox mbox (SupervisorMessage n)) => mbox (SupervisorMessage n) -> m () Source #

Stop the supervisor and its children.