@@ -45,6 +45,8 @@ module Control.Distributed.Process.UnsafePrimitives
46 , sendChan
46 , sendChan
48 , wrapMessage
50 , wrapMessage
@@ -56,6 +58,7 @@ import Control.Distributed.Process.Internal.Messaging
57import Control.Distributed.Process.Internal.Types
59import Control.Distributed.Process.Internal.Types
58 ( ProcessId(..)
60 ( ProcessId(..)
59 , LocalNode(..)
62 , LocalNode(..)
60 , LocalProcess(..)
63 , LocalProcess(..)
61 , Process(..)
64 , Process(..)
@@ -65,6 +68,7 @@ import Control.Distributed.Process.Internal.Types
65 , ImplicitReconnect(..)
68 , ImplicitReconnect(..)
66 , SendPortId(..)
69 , SendPortId(..)
68 , sendPortProcessId
72 , sendPortProcessId
69 , unsafeCreateUnencodedMessage
73 , unsafeCreateUnencodedMessage
@@ -78,6 +82,14 @@ nsend :: Serializable a => String -> a -> Process ()
78nsend label msg =
82nsend label msg =
79 sendCtrlMsg Nothing (NamedSend label (unsafeCreateUnencodedMessage msg))
83 sendCtrlMsg Nothing (NamedSend label (unsafeCreateUnencodedMessage msg))
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
89+ if localNodeId (processNode proc) == nid
91+ else sendCtrlMsg (Just nid) (NamedSend label (createMessage msg))
81-- | Send a message
93-- | Send a message
82send :: Serializable a => ProcessId -> a -> Process ()
94send :: Serializable a => ProcessId -> a -> Process ()
83send them msg = do
95send them msg = do
@@ -96,6 +108,25 @@ send them msg = do
96 unsafeSendLocal pid msg' =
108 unsafeSendLocal pid msg' =
97 sendCtrlMsg Nothing $ LocalSend pid (unsafeCreateUnencodedMessage msg')
109 sendCtrlMsg Nothing $ LocalSend pid (unsafeCreateUnencodedMessage msg')
111+-- | Send a message unreliably.
113+-- Unlike 'send', this function is insensitive to 'reconnect'. It will
114+-- try to send the message regardless of the history of connection failures
115+-- between the nodes.
117+-- Message passing with 'usend' is ordered for a given sender and receiver
118+-- if the messages arrive at all.
120+usend :: Serializable a => ProcessId -> a -> Process ()
123+ let there = processNodeId them
124+ if localNodeId (processNode proc) == there
125+ then sendCtrlMsg Nothing $
126+ LocalSend them (unsafeCreateUnencodedMessage msg)
127+ else sendCtrlMsg (Just there) $ UnreliableSend (processLocalId them)
99-- | Send a message on a typed channel
130-- | Send a message on a typed channel
100sendChan :: Serializable a => SendPort a -> a -> Process ()
131sendChan :: Serializable a => SendPort a -> a -> Process ()
101sendChan (SendPort cid) msg = do
132sendChan (SendPort cid) msg = do