@@ -225,13 +225,14 @@ workLoopFIFO q st sv winfo = run
225225 res <- liftIO $ sendYield sv winfo (ChildYield a)
226226 return $ if res then Continue else Suspend
227227
228+ -- XXX in general we would like to yield "n" elements from a single stream
229+ -- before moving on to the next. Single element granularity could be too
230+ -- expensive in certain cases. Similarly, we can use time limit for
231+ -- yielding.
228232 yieldk a r = do
229233 res <- liftIO $ sendYield sv winfo (ChildYield a)
230− if res
231− then foldStreamShared st yieldk single (return Continue) r
232− else liftIO $ do
233− enqueueFIFO sv q r
234− return Suspend
234+ liftIO $ enqueueFIFO sv q r
235+ return $ if res then Continue else Suspend
235236
236237{-# INLINE workLoopFIFOLimited #-}
237238workLoopFIFOLimited
@@ -273,12 +274,12 @@ workLoopFIFOLimited q st sv winfo = run
273274
274275 yieldk a r = do
275276 res <- liftIO $ sendYield sv winfo (ChildYield a)
277+ liftIO $ enqueueFIFO sv q r
276278 yieldLimitOk <- liftIO $ decrementYieldLimit sv
277279 if res && yieldLimitOk
278− then foldStreamShared st yieldk single incrContinue r
280+ then return Continue
279281 else liftIO $ do
280282 incrementYieldLimit sv
281− enqueueFIFO sv q r
282283 return Suspend
283284
284285-------------------------------------------------------------------------------