@@ -45,6 +45,7 @@ module Control.Distributed.Process.UnsafePrimitives
4545 send
4646 , sendChan
4747 , nsend
48+ , usend
4849 , wrapMessage
4950 ) where
5051
@@ -65,6 +66,7 @@ import Control.Distributed.Process.Internal.Types
6566 , ImplicitReconnect(..)
6667 , SendPortId(..)
6768 , Message
69+ , createMessage
6870 , sendPortProcessId
6971 , unsafeCreateUnencodedMessage
7072 )
@@ -96,6 +98,25 @@ send them msg = do
9698 unsafeSendLocal pid msg' =
9799 sendCtrlMsg Nothing $ LocalSend pid (unsafeCreateUnencodedMessage msg')
98100
101+-- | Send a message unreliably.
102+--
103+-- Unlike 'send', this function is insensitive to 'reconnect'. It will
104+-- try to send the message regardless of the history of connection failures
105+-- between the nodes.
106+--
107+-- Message passing with 'usend' is ordered for a given sender and receiver
108+-- if the messages arrive at all.
109+--
110+usend :: Serializable a => ProcessId -> a -> Process ()
111+usend them msg = do
112+ proc <- ask
113+ let there = processNodeId them
114+ if localNodeId (processNode proc) == there
115+ then sendCtrlMsg Nothing $
116+ LocalSend them (unsafeCreateUnencodedMessage msg)
117+ else sendCtrlMsg (Just there) $ UnreliableSend (processLocalId them)
118+ (createMessage msg)
119+
99120-- | Send a message on a typed channel
100121sendChan :: Serializable a => SendPort a -> a -> Process ()
101122sendChan (SendPort cid) msg = do