distributed-process
distributed-process copied to clipboard
spawnChannel doesn't look right
-- | Spawn a new process, supplying it with a new 'ReceivePort' and return
-- the corresponding 'SendPort'.
spawnChannel :: forall a. Typeable a => Static (SerializableDict a)
-> NodeId
-> Closure (ReceivePort a -> Process ())
-> Process (SendPort a)
spawnChannel dict nid proc = do
us <- getSelfPid
spawn nid (go us)
expect
where
go :: ProcessId -> Closure (Process ())
go pid = cpNewChan dict
`bindCP`
(cpSend (sdictSendPort dict) pid `splitCP` proc)
`bindCP`
(idCP `closureCompose` staticClosure sndStatic)
That expect might pick up the wrong SendPort - I think we need to create a channel for the reply first.
Thanks for spotting that @simonmar - it looks like a simple (ish) fix, so I'll have a look at it over the next day or so.
There's actually a secondary problem with spawnChannel: #271 .
We're currently experimenting with a module that fixes both this ticket and #271.