git.iko.soy/distributed-process
on master help sign in
Prepare for changing withMonitor.
6c04653Alexander Vershilov
src/Control/Distributed/Process.hs+2−2
@@ -102,7 +102,7 @@ module Control.Distributed.Process
102 , monitorPort
102 , monitorPort
103 , unmonitor
103 , unmonitor
104 , withMonitor
104 , withMonitor
105− , withMonitorRef
105+ , withMonitor_
106 , MonitorRef -- opaque
106 , MonitorRef -- opaque
107 , ProcessLinkException(..)
107 , ProcessLinkException(..)
108 , NodeLinkException(..)
108 , NodeLinkException(..)
@@ -270,7 +270,7 @@ import Control.Distributed.Process.Internal.Primitives
270 , monitorPort
270 , monitorPort
271 , unmonitor
271 , unmonitor
272 , withMonitor
272 , withMonitor
273− , withMonitorRef
273+ , withMonitor_
274 -- Logging
274 -- Logging
275 , say
275 , say
276 -- Registry
276 -- Registry
src/Control/Distributed/Process/Internal/Primitives.hs+10−11
@@ -77,7 +77,7 @@ module Control.Distributed.Process.Internal.Primitives
77 , monitor
77 , monitor
78 , unmonitor
78 , unmonitor
79 , withMonitor
79 , withMonitor
80− , withMonitorRef
80+ , withMonitor_
81 -- * Logging
81 -- * Logging
82 , say
82 , say
83 -- * Registry
83 -- * Registry
@@ -888,20 +888,19 @@ monitor = monitor' . ProcessIdentifier
888-- messages in the queue.
888-- messages in the queue.
889--
889--
890withMonitor :: ProcessId -> Process a -> Process a
890withMonitor :: ProcessId -> Process a -> Process a
891−withMonitor pid = withMonitorRef pid . const
891+withMonitor pid = bracket (monitor pid) unmonitor . const
892− -- unmonitor blocks waiting for the response, so there's a possibility
892+{-# WARNING withMonitor "Signature of this function will be changed to 'ProcessId -> (MonitorRef -> Process a) -> Process a' in the next release, for stable behaviour use withMonitor_" #-}
893− -- that an exception might interrupt withMonitor before the unmonitor
894− -- has completed. I think that's better than making the unmonitor
895− -- uninterruptible.
896
893
897-- | Establishes temporary monitoring of another process.
894-- | Establishes temporary monitoring of another process.
898--
895--
899−-- @withMonitorRef pid code@ sets up monitoring of @pid@ for the duration
896+-- @withMonitor_ pid code@ sets up monitoring of @pid@ for the duration
900−-- of @code@. Note: although monitoring is no longer active when
897+-- of @code@. Note: although monitoring is no longer active when
901−-- @withMonitorRef@ returns, there might still be unreceived monitor
898+-- @withMonitor_@ returns, there might still be unreceived monitor
902-- messages in the queue.
899-- messages in the queue.
900+--
901+-- Since 0.6.1
903−withMonitorRef :: ProcessId -> (MonitorRef -> Process a) -> Process a
902+withMonitor_ :: ProcessId -> Process a -> Process a
904−withMonitorRef pid code = bracket (monitor pid) unmonitor code
903+withMonitor_ = withMonitor
905
904
906-- | Remove a link
905-- | Remove a link
907--
906--