git.iko.soy/distributed-process
on master help sign in
block on all mx reads
commitf0f6a7200f58332de9c0f3d025bd067679cf5364 authorTim Watson <watson.timothy@gmail.com> dateFri 16 May 2014, 10:48 (12 years ago) parent4997a80
1 file changed+4−15
src/Control/Distributed/Process/Management.hs+4−15
src/Control/Distributed/Process/Management.hs+4−15
@@ -58,10 +58,9 @@
5858-- data stream will be checked first. No blocking will occur if the chosen
5959-- (prioritised) source is devoid of input messages, instead the agent handling
6060-- code will revert to switching between the alternatives in /round-robin/ as
61−-- usual. This switching (and prioritisation) will take place a limited number
62−-- of times, after which - in order to avoid over-utilising system
63−-- resources - the agent will revert to blocking on the event bus (and ignoring
64−-- its mailbox).
61+-- usual. If messages exist in one or more channels, they will be consumed as
62+-- soon as they're available, priority is effectively a hint about which
63+-- channel to consume from, should messages be available in both.
6564--
6665-- Prioritisation then, is a /hint/ about the preference of data source from
6766-- which the next input should be chosen. No guarantee can be made that the
@@ -534,17 +533,7 @@ mxAgentWithFinalize mxId initState handlers dtor = do
534533 , matchSTM (readTChan chan) return]
535534 InputChan -> [ matchSTM (readTChan chan) return
536535 , matchAny return]
537− in getNextInput' matches 0
538−
539− getNextInput' ms n = do
540− mIn <- receiveTimeout n ms
541− case mIn of
542− Nothing -> tryNextInput ms n
543− Just msg -> return msg
544−
545− tryNextInput ms n
546− | n > 0 && n < 2000 = getNextInput' ms $ n * 2
547− | otherwise = getNextInput' ms 100
536+ in receiveWait matches
548537
549538 runAgentFinalizer :: MxAgent s () -> MxAgentState s -> Process ()
550539 runAgentFinalizer f s = ST.runStateT (unAgent f) s >>= return . fst