git.iko.soy/distributed-process
on master help sign in
implement 'die' - terminates the calling process immediately by

throwing ProcessExitException with the supplied reason. Closes #110.

commit414d9581df0b033993d46a4ecfe886a08dbc712d authorTim Watson <tim@rabbitmq.com> dateWed 16 Jan 2013, 23:44 (14 years ago) parent9f5ce46
1 file changed+8
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+8
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+8
@@ -25,6 +25,7 @@ module Control.Distributed.Process.Internal.Primitives
2525 -- * Process management
2626 , terminate
2727 , ProcessTerminationException(..)
28+ , die
2829 , kill
2930 , exit
3031 , catchExit
@@ -346,6 +347,13 @@ instance Exception ProcessTerminationException
346347terminate :: Process a
347348terminate = liftIO $ throwIO ProcessTerminationException
348349
350+-- [Issue #110]
351+-- | Die immediately - throws a 'ProcessExitException' with the given @reason@
352+die :: Serializable a => a -> Process b
353+die reason = do
354+ pid <- getSelfPid
355+ liftIO $ throwIO (ProcessExitException pid (createMessage reason))
356+
349357-- | Forceful request to kill a process
350358kill :: ProcessId -> String -> Process ()
351359-- NOTE: We send the message to our local node controller, which will then