Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
data Interrupt :: Effect where Source #
The interrupt handler effect allows three kinds of interaction for interrupt signals:
- Execute a callback when a signal is received
- Block a thread until a signal is received
- Kill a thread when a signal is received
For documentation on the constructors, see the module Polysemy.Conc.Effect.Interrupt.
import qualified Polysemy.Conc.Effect.Interrupt as Interrupt prog = do Interrupt.register "task 1" (putStrLn "interrupted") Interrupt.killOnQuit $ forever do doSomeWork
Register :: Text -> IO () -> Interrupt m () | Add a computation to be executed on interrupt, using the first argument as a key. |
Unregister :: Text -> Interrupt m () | Remove the previously added handler with the given key. |
Quit :: Interrupt m () | Manually trigger the interrupt. |
WaitQuit :: Interrupt m () | Block until an interrupt is triggered. |
Interrupted :: Interrupt m Bool | Indicate whether an interrupt was triggered. |
KillOnQuit :: Text -> m a -> Interrupt m (Maybe a) | Execute a computation, waiting for it to finish, killing its thread on interrupt. |
Instances
type DefiningModule Interrupt Source # | |
Defined in Polysemy.Conc.Effect.Interrupt |
killOnQuit_ :: Member Interrupt r => Text -> Sem r a -> Sem r () Source #
Variant of killOnQuit
that returns ()
.