distributed-process icon indicating copy to clipboard operation
distributed-process copied to clipboard

spawnChannel doesn't look right

Open simonmar opened this issue 12 years ago • 3 comments

-- | 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.

simonmar avatar Dec 20 '12 15:12 simonmar

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.

hyperthunk avatar Dec 20 '12 16:12 hyperthunk

There's actually a secondary problem with spawnChannel: #271 .

edsko avatar Feb 04 '16 10:02 edsko

We're currently experimenting with a module that fixes both this ticket and #271.

edsko avatar Feb 04 '16 13:02 edsko