git.iko.soy/distributed-process
on master help sign in
Skip the transport for whereisRemoteAsync and registerRemoteAsync.

The transport is skipped when the destination is the local node.

commit17c06e6bdd2a221d076fd11b9f0819550c0bc73f authorFacundo Domínguez <facundo.dominguez@tweag.io> dateTue 1 Dec 2015, 13:33 (11 years ago) parentc67b972
1 file changed+7−4
src/Control/Distributed/Process/Internal/Primitives.hs+7−4
src/Control/Distributed/Process/Internal/Primitives.hs+7−4
@@ -1103,8 +1103,10 @@ registerImpl force label pid = do
11031103--
11041104-- See comments in 'whereisRemoteAsync'
11051105registerRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
1106−registerRemoteAsync nid label pid =
1107− sendCtrlMsg (Just nid) (Register label nid (Just pid) False)
1106+registerRemoteAsync nid label pid = do
1107+ here <- getSelfNode
1108+ sendCtrlMsg (if nid == here then Nothing else Just nid)
1109+ (Register label nid (Just pid) False)
11081110
11091111reregisterRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
11101112reregisterRemoteAsync nid label pid =
@@ -1156,8 +1158,9 @@ whereis label = do
11561158-- use 'monitorNode' and take appropriate action when you receive a
11571159-- 'NodeMonitorNotification').
11581160whereisRemoteAsync :: NodeId -> String -> Process ()
1159−whereisRemoteAsync nid label =
1160− sendCtrlMsg (Just nid) (WhereIs label)
1161+whereisRemoteAsync nid label = do
1162+ here <- getSelfNode
1163+ sendCtrlMsg (if nid == here then Nothing else Just nid) (WhereIs label)
11611164
11621165-- | Named send to a process in the local registry (asynchronous)
11631166nsend :: Serializable a => String -> a -> Process ()