Skip to content

Have nsendRemote skip the transport for local communication. #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/Control/Distributed/Process/Internal/Primitives.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,10 @@ registerImpl force label pid = do
--
-- See comments in 'whereisRemoteAsync'
registerRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
registerRemoteAsync nid label pid =
sendCtrlMsg (Just nid) (Register label nid (Just pid) False)
registerRemoteAsync nid label pid = do
here <- getSelfNode
sendCtrlMsg (if nid == here then Nothing else Just nid)
(Register label nid (Just pid) False)

reregisterRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
reregisterRemoteAsync nid label pid =
Expand Down Expand Up @@ -1156,8 +1158,9 @@ whereis label = do
-- use 'monitorNode' and take appropriate action when you receive a
-- 'NodeMonitorNotification').
whereisRemoteAsync :: NodeId -> String -> Process ()
whereisRemoteAsync nid label =
sendCtrlMsg (Just nid) (WhereIs label)
whereisRemoteAsync nid label = do
here <- getSelfNode
sendCtrlMsg (if nid == here then Nothing else Just nid) (WhereIs label)

-- | Named send to a process in the local registry (asynchronous)
nsend :: Serializable a => String -> a -> Process ()
Expand All @@ -1173,8 +1176,10 @@ unsafeNSend = Unsafe.nsend

-- | Named send to a process in a remote registry (asynchronous)
nsendRemote :: Serializable a => NodeId -> String -> a -> Process ()
nsendRemote nid label msg =
sendCtrlMsg (Just nid) (NamedSend label (createMessage msg))
nsendRemote nid label msg = do
here <- getSelfNode
if here == nid then nsend label msg
else sendCtrlMsg (Just nid) (NamedSend label (createMessage msg))

--------------------------------------------------------------------------------
-- Closures --
Expand Down