@@ -89,6 +89,9 @@ module Control.Distributed.Process
89 , spawnMonitor
89 , spawnMonitor
90 , spawnChannel
90 , spawnChannel
91 , DidSpawn(..)
91 , DidSpawn(..)
92+ -- * Local versions of spawn
@@ -121,6 +124,7 @@ import Control.Distributed.Process.Internal.Types
121 , SerializableDict(..)
124 , SerializableDict(..)
122 , SendPortId(..)
125 , SendPortId(..)
123 , WhereIsReply(..)
126 , WhereIsReply(..)
125import Control.Distributed.Process.Internal.Closure.CP
129import Control.Distributed.Process.Internal.Closure.CP
@@ -190,6 +194,8 @@ import Control.Distributed.Process.Internal.Primitives
190 , spawnAsync
194 , spawnAsync
192import Control.Distributed.Process.Serializable (Serializable)
196import Control.Distributed.Process.Serializable (Serializable)
197+import Control.Distributed.Process.Internal.MessageT (getLocalNode)
198+import Control.Distributed.Process.Node (forkProcess)
194-- INTERNAL NOTES
200-- INTERNAL NOTES
@@ -355,3 +361,24 @@ spawnChannel dict nid proc = do
355 (cpSend (sdictSendPort dict) pid `cpSplit` proc)
361 (cpSend (sdictSendPort dict) pid `cpSplit` proc)
357 cpCancelL
363 cpCancelL
365+--------------------------------------------------------------------------------
366+-- Local versions of spawn --
367+--------------------------------------------------------------------------------
369+-- | Spawn a process on the local node
370+spawnLocal :: Process () -> Process ProcessId
372+ node <- procMsg $ getLocalNode
373+ liftIO $ forkProcess node proc
375+-- | Create a new typed channel, spawn a process on the local node, passing it
376+-- the receive port, and return the send port
377+spawnChannelLocal :: Serializable a
378+ => (ReceivePort a -> Process ())
379+ -> Process (SendPort a)
380+spawnChannelLocal proc = do
381+ node <- procMsg $ getLocalNode
382+ (sport, rport) <- newChan
383+ _ <- liftIO $ forkProcess node (proc rport)