git.iko.soy/distributed-process
on master help sign in
Fix race in spawn (DP-99).
10d72bbFacundo Domínguez
src/Control/Distributed/Process/Internal/Closure/BuiltIn.hs+3−2
@@ -295,15 +295,16 @@ cpEnableTraceRemote =
295-- | @delay them p@ is a process that waits for a signal (a message of type @()@)
295-- | @delay them p@ is a process that waits for a signal (a message of type @()@)
296-- from 'them' (origin is not verified) before proceeding as @p@. In order to
296-- from 'them' (origin is not verified) before proceeding as @p@. In order to
297-- avoid waiting forever, @delay them p@ monitors 'them'. If it receives a
297-- avoid waiting forever, @delay them p@ monitors 'them'. If it receives a
298−-- monitor message instead it simply terminates.
298+-- monitor message instead, it proceeds as @p@ too.
299delay :: ProcessId -> Process () -> Process ()
299delay :: ProcessId -> Process () -> Process ()
300delay them p = do
300delay them p = do
301 ref <- monitor them
301 ref <- monitor them
302 let sameRef (ProcessMonitorNotification ref' _ _) = ref == ref'
302 let sameRef (ProcessMonitorNotification ref' _ _) = ref == ref'
303 receiveWait [
303 receiveWait [
304− match $ \() -> unmonitor ref >> p
304+ match $ \() -> unmonitor ref
305 , matchIf sameRef $ \_ -> return ()
305 , matchIf sameRef $ \_ -> return ()
306 ]
306 ]
307+ p
307
308
308-- | 'CP' version of 'delay'
309-- | 'CP' version of 'delay'
309cpDelay :: ProcessId -> Closure (Process ()) -> Closure (Process ())
310cpDelay :: ProcessId -> Closure (Process ()) -> Closure (Process ())