git.iko.soy/distributed-process
on master help sign in
Clarify the sync/async nature of some primitives
commit65b27987245aa2bf4744b1e22ea672001d4463ff authorEdsko de Vries <edsko@edsko.net> dateThu 23 Aug 2012, 13:33 (14 years ago) parent301d2cd
1 file changed+22−9
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+22−9
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+22−9
@@ -297,7 +297,12 @@ link = sendCtrlMsg Nothing . Link . ProcessIdentifier
297297monitor :: ProcessId -> Process MonitorRef
298298monitor = monitor' . ProcessIdentifier
299299
300−-- | Remove a link (synchronous)
300+-- | Remove a link
301+--
302+-- This is synchronous in the sense that once it returns you are guaranteed
303+-- that no exception will be raised if the remote process dies. However, it is
304+-- asynchronous in the sense that we do not wait for a response from the remote
305+-- node.
301306unlink :: ProcessId -> Process ()
302307unlink pid = do
303308 unlinkAsync pid
@@ -305,7 +310,9 @@ unlink pid = do
305310 (\_ -> return ())
306311 ]
307312
308−-- | Remove a node link (synchronous)
313+-- | Remove a node link
314+--
315+-- This has the same synchronous/asynchronous nature as 'unlink'.
309316unlinkNode :: NodeId -> Process ()
310317unlinkNode nid = do
311318 unlinkNodeAsync nid
@@ -313,7 +320,9 @@ unlinkNode nid = do
313320 (\_ -> return ())
314321 ]
315322
316−-- | Remove a channel (send port) link (synchronous)
323+-- | Remove a channel (send port) link
324+--
325+-- This has the same synchronous/asynchronous nature as 'unlink'.
317326unlinkPort :: SendPort a -> Process ()
318327unlinkPort sport = do
319328 unlinkPortAsync sport
@@ -321,7 +330,9 @@ unlinkPort sport = do
321330 (\_ -> return ())
322331 ]
323332
324−-- | Remove a monitor (synchronous)
333+-- | Remove a monitor
334+--
335+-- This has the same synchronous/asynchronous nature as 'unlink'.
325336unmonitor :: MonitorRef -> Process ()
326337unmonitor ref = do
327338 unmonitorAsync ref
@@ -388,12 +399,12 @@ spawnAsync nid proc = do
388399 sendCtrlMsg (Just nid) $ Spawn proc spawnRef
389400 return spawnRef
390401
391−-- | Monitor a node
402+-- | Monitor a node (asynchronous)
392403monitorNode :: NodeId -> Process MonitorRef
393404monitorNode =
394405 monitor' . NodeIdentifier
395406
396−-- | Monitor a typed channel
407+-- | Monitor a typed channel (asynchronous)
397408monitorPort :: forall a. Serializable a => SendPort a -> Process MonitorRef
398409monitorPort (SendPort cid) =
399410 monitor' (SendPortIdentifier cid)
@@ -403,11 +414,11 @@ unmonitorAsync :: MonitorRef -> Process ()
403414unmonitorAsync =
404415 sendCtrlMsg Nothing . Unmonitor
405416
406−-- | Link to a node
417+-- | Link to a node (asynchronous)
407418linkNode :: NodeId -> Process ()
408419linkNode = link' . NodeIdentifier
409420
410−-- | Link to a channel (send port)
421+-- | Link to a channel (asynchronous)
411422linkPort :: SendPort a -> Process ()
412423linkPort (SendPort cid) =
413424 link' (SendPortIdentifier cid)
@@ -471,7 +482,7 @@ unregisterRemote :: NodeId -> String -> Process ()
471482unregisterRemote nid label =
472483 sendCtrlMsg (Just nid) (Register label Nothing)
473484
474−-- | Query the local process registry (synchronous).
485+-- | Query the local process registry
475486whereis :: String -> Process (Maybe ProcessId)
476487whereis label = do
477488 sendCtrlMsg Nothing (WhereIs label)
@@ -480,6 +491,8 @@ whereis label = do
480491 ]
481492
482493-- | Query a remote process registry (synchronous)
494+--
495+-- TODO: what if the remote node is unreachable?
483496whereisRemote :: NodeId -> String -> Process (Maybe ProcessId)
484497whereisRemote nid label = do
485498 whereisRemoteAsync nid label