File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ module Control.Distributed.Process
43
43
, unsafeUSend
44
44
, unsafeSendChan
45
45
, unsafeNSend
46
+ , unsafeNSendRemote
46
47
, unsafeWrapMessage
47
48
-- * Advanced messaging
48
49
, Match
@@ -216,6 +217,7 @@ import Control.Distributed.Process.Internal.Primitives
216
217
, unsafeUSend
217
218
, unsafeSendChan
218
219
, unsafeNSend
220
+ , unsafeNSendRemote
219
221
-- Advanced messaging
220
222
, Match
221
223
, receiveWait
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ module Control.Distributed.Process.Internal.Primitives
26
26
, unsafeUSend
27
27
, unsafeSendChan
28
28
, unsafeNSend
29
+ , unsafeNSendRemote
29
30
-- * Advanced messaging
30
31
, Match
31
32
, receiveWait
@@ -1184,6 +1185,13 @@ nsendRemote :: Serializable a => NodeId -> String -> a -> Process ()
1184
1185
nsendRemote nid label msg =
1185
1186
sendCtrlMsg (Just nid) (NamedSend label (createMessage msg))
1186
1187
1188
+ -- | Named send to a process in a remote registry (asynchronous)
1189
+ -- This function makes /no/ attempt to serialize and (in the case when the
1190
+ -- destination process resides on the same local node) therefore ensure that
1191
+ -- the payload is fully evaluated before it is delivered.
1192
+ unsafeNSendRemote :: Serializable a => NodeId -> String -> a -> Process ()
1193
+ unsafeNSendRemote = Unsafe. nsendRemote
1194
+
1187
1195
--------------------------------------------------------------------------------
1188
1196
-- Closures --
1189
1197
--------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ module Control.Distributed.Process.UnsafePrimitives
45
45
send
46
46
, sendChan
47
47
, nsend
48
+ , nsendRemote
48
49
, usend
49
50
, wrapMessage
50
51
) where
@@ -57,6 +58,7 @@ import Control.Distributed.Process.Internal.Messaging
57
58
58
59
import Control.Distributed.Process.Internal.Types
59
60
( ProcessId (.. )
61
+ , NodeId (.. )
60
62
, LocalNode (.. )
61
63
, LocalProcess (.. )
62
64
, Process (.. )
@@ -80,6 +82,14 @@ nsend :: Serializable a => String -> a -> Process ()
80
82
nsend label msg =
81
83
sendCtrlMsg Nothing (NamedSend label (unsafeCreateUnencodedMessage msg))
82
84
85
+ -- | Named send to a process in a remote registry (asynchronous)
86
+ nsendRemote :: Serializable a => NodeId -> String -> a -> Process ()
87
+ nsendRemote nid label msg = do
88
+ proc <- ask
89
+ if localNodeId (processNode proc ) == nid
90
+ then nsend label msg
91
+ else sendCtrlMsg (Just nid) (NamedSend label (createMessage msg))
92
+
83
93
-- | Send a message
84
94
send :: Serializable a => ProcessId -> a -> Process ()
85
95
send them msg = do
You can’t perform that action at this time.
0 commit comments