@@ -14,6 +14,10 @@ module Control.Distributed.Process.Internal.Primitives
14 , receiveChan
14 , receiveChan
15 , mergePortsBiased
15 , mergePortsBiased
16 , mergePortsRR
16 , mergePortsRR
17+ -- * Unsafe messaging variants
17 -- * Advanced messaging
21 -- * Advanced messaging
19 , receiveWait
23 , receiveWait
@@ -93,6 +97,8 @@ module Control.Distributed.Process.Internal.Primitives
93 -- * Reconnecting
97 -- * Reconnecting
94 , reconnect
98 , reconnect
95 , reconnectPort
99 , reconnectPort
100+ -- * Internal Exports
98#if ! MIN_VERSION_base(4,6,0)
104#if ! MIN_VERSION_base(4,6,0)
@@ -138,6 +144,7 @@ import Control.Distributed.Static
139import Data.Rank1Typeable (Typeable)
145import Data.Rank1Typeable (Typeable)
140import qualified Control.Distributed.Static as Static (unstatic, unclosure)
146import qualified Control.Distributed.Static as Static (unstatic, unclosure)
147+import qualified Control.Distributed.Process.UnsafePrimitives as Unsafe
141import Control.Distributed.Process.Internal.Types
148import Control.Distributed.Process.Internal.Types
142 ( NodeId(..)
149 ( NodeId(..)
143 , ProcessId(..)
150 , ProcessId(..)
@@ -181,6 +188,7 @@ import Control.Distributed.Process.Internal.Messaging
181 , sendBinary
188 , sendBinary
182 , sendPayload
189 , sendPayload
183 , disconnect
190 , disconnect
185import Control.Distributed.Process.Internal.Trace.Types
193import Control.Distributed.Process.Internal.Trace.Types
186 ( traceEvent
194 ( traceEvent
@@ -220,6 +228,13 @@ send them msg = do
220 liftIO $ traceEvent (localTracer node)
228 liftIO $ traceEvent (localTracer node)
221 (TraceEvSent them us (createUnencodedMessage msg))
229 (TraceEvSent them us (createUnencodedMessage msg))
231+-- | /Unsafe/ variant of 'send'. This function makes /no/ attempt to serialize
232+-- and (in the case when the destination process resides on the same local
233+-- node) therefore ensure that the payload is fully evaluated before it is
235+unsafeSend :: Serializable a => ProcessId -> a -> Process ()
236+unsafeSend = Unsafe.send
223-- | Wait for a message of a specific type
238-- | Wait for a message of a specific type
224expect :: forall a. Serializable a => Process a
239expect :: forall a. Serializable a => Process a
225expect = receiveWait [match return]
240expect = receiveWait [match return]
@@ -267,6 +282,13 @@ sendChan (SendPort cid) msg = do
267 NoImplicitReconnect
282 NoImplicitReconnect
285+-- | Send a message on a typed channel. This function makes /no/ attempt to
286+-- serialize and (in the case when the @ReceivePort@ resides on the same local
287+-- node) therefore ensure that the payload is fully evaluated before it is
289+unsafeSendChan :: Serializable a => SendPort a -> a -> Process ()
290+unsafeSendChan = Unsafe.sendChan
270-- | Wait for a message on a typed channel
292-- | Wait for a message on a typed channel
271receiveChan :: Serializable a => ReceivePort a -> Process a
293receiveChan :: Serializable a => ReceivePort a -> Process a
272receiveChan = liftIO . atomically . receiveSTM
294receiveChan = liftIO . atomically . receiveSTM
@@ -986,6 +1008,13 @@ nsend :: Serializable a => String -> a -> Process ()
986nsend label msg =
1008nsend label msg =
987 sendCtrlMsg Nothing (NamedSend label (createUnencodedMessage msg))
1009 sendCtrlMsg Nothing (NamedSend label (createUnencodedMessage msg))
1011+-- | Named send to a process in the local registry (asynchronous).
1012+-- This function makes /no/ attempt to serialize and (in the case when the
1013+-- destination process resides on the same local node) therefore ensure that
1014+-- the payload is fully evaluated before it is delivered.
1015+unsafeNSend :: Serializable a => String -> a -> Process ()
1016+unsafeNSend = Unsafe.nsend
989-- | Named send to a process in a remote registry (asynchronous)
1018-- | Named send to a process in a remote registry (asynchronous)
990nsendRemote :: Serializable a => NodeId -> String -> a -> Process ()
1019nsendRemote :: Serializable a => NodeId -> String -> a -> Process ()
991nsendRemote nid label msg =
1020nsendRemote nid label msg =
@@ -1091,22 +1120,3 @@ monitor' ident = do
1091-- | Link to a process/node/channel
1120-- | Link to a process/node/channel
1092link' :: Identifier -> Process ()
1121link' :: Identifier -> Process ()
1093link' = sendCtrlMsg Nothing . Link
1122link' = sendCtrlMsg Nothing . Link
1095−-- Send a control message
1096−sendCtrlMsg :: Maybe NodeId -- ^ Nothing for the local node
1097− -> ProcessSignal -- ^ Message to send
1099−sendCtrlMsg mNid signal = do
1101− let msg = NCMsg { ctrlMsgSender = ProcessIdentifier (processId proc)
1102− , ctrlMsgSignal = signal
1106− liftIO $ writeChan (localCtrlChan (processNode proc)) msg
1108− liftIO $ sendBinary (processNode proc)
1109− (ProcessIdentifier (processId proc))
1110− (NodeIdentifier nid)
1111− WithImplicitReconnect