git.iko.soy/distributed-process
on master help sign in
Merge pull request #182 from qnikst/queue-size-info

Return size of the queue in ProcessInfo.

commitc7fb158da1925b99adcc3d69fb96f6dfec8ddd77 authorTim Watson <watson.timothy@gmail.com> dateSat 7 Mar 2015, 07:43 (12 years ago) parent4d3472ad63e025
2 files changed+5−4
src/Control/Distributed/Process/Internal/Types.hs+1−1 src/Control/Distributed/Process/Node.hs+4−3
src/Control/Distributed/Process/Internal/Types.hs+1−1
@@ -542,7 +542,7 @@ data NodeStats = NodeStats {
542542data ProcessInfo = ProcessInfo {
543543 infoNode :: NodeId
544544 , infoRegisteredNames :: [String]
545− , infoMessageQueueLength :: Maybe Int
545+ , infoMessageQueueLength :: Int
546546 , infoMonitors :: [(ProcessId, MonitorRef)]
547547 , infoLinks :: [ProcessId]
548548 } deriving (Show, Eq, Typeable)
src/Control/Distributed/Process/Node.hs+4−3
@@ -88,6 +88,7 @@ import Control.Distributed.Process.Internal.CQueue
8888 , enqueue
8989 , newCQueue
9090 , mkWeakCQueue
91+ , queueSize
9192 )
9293import qualified Network.Transport as NT
9394 ( Transport
@@ -974,10 +975,11 @@ ncEffectGetInfo from pid =
974975 case mProc of
975976 Nothing -> dispatch (isLocal node (ProcessIdentifier from))
976977 from node (ProcessInfoNone DiedUnknownId)
977− Just _ -> do
978+ Just proc -> do
978979 itsLinks <- gets (^. linksFor them)
979980 itsMons <- gets (^. monitorsFor them)
980981 registered <- gets (^. registeredHere)
982+ size <- liftIO $ queueSize $ processQueue $ proc
981983
982984 let reg = registeredNames registered
983985 dispatch (isLocal node (ProcessIdentifier from))
@@ -986,8 +988,7 @@ ncEffectGetInfo from pid =
986988 ProcessInfo {
987989 infoNode = (processNodeId pid)
988990 , infoRegisteredNames = reg
989− -- we cannot populate this field
990− , infoMessageQueueLength = Nothing
991+ , infoMessageQueueLength = size
991992 , infoMonitors = Set.toList itsMons
992993 , infoLinks = Set.toList itsLinks
993994 }