Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Interrupt :: Effect where
- killOnQuit_ :: Member Interrupt r => Text -> Sem r a -> Sem r ()
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.Data.Interrupt.
import qualified Polysemy.Conc.Data.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.Data.Interrupt type DefiningModule Interrupt = "Polysemy.Conc.Data.Interrupt" |
killOnQuit_ :: Member Interrupt r => Text -> Sem r a -> Sem r () Source #
Variant of killOnQuit
that returns ()
.