Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
TheatreDev.Daemon
Contents
Documentation
Think of an actor that does not process any messages and simply interrupts between each iteration to check whether it's still alive.
Acquisition
Arguments
:: state | Initial state of the daemon. |
-> (state -> IO state) | Iteration action, updating the daemon's state. It gets executed in a loop, with checks of whether the daemon is still alive after each one. Killing the daemon will not interrupt the currently ongoing iteration, thus providing gracefulness guarantees. If an exception is thrown by this action,
the iteration loop will stop,
the |
-> (state -> IO ()) | Clean up after the iteration loop is stopped. You can use that to release resources or issue notifications about the daemon dying. |
-> IO Daemon |
Fork a thread to run the daemon loop on returning immediately with a handle to control it.