mirror of
https://github.com/ilyakooo0/streamly.git
synced 2024-09-11 08:25:40 +03:00
Fix scheduling of WAsync style stream
We were scheduling it in the same manner as Async, instead we have to schedule the actions from the two streams in a round robin fashion. Fixes #371
This commit is contained in:
parent
d35674ea02
commit
3f5c79ea94
@ -11,6 +11,7 @@
|
||||
stream, especially when built with `-threaded` and used with `-N` RTS option.
|
||||
The issue occurs only in cases when a worker thread happens to be used
|
||||
continuously for a long time.
|
||||
* Fix scheduling of WAsyncT stream style to be in round-robin fashion.
|
||||
|
||||
### Behavior change
|
||||
|
||||
|
@ -225,13 +225,14 @@ workLoopFIFO q st sv winfo = run
|
||||
res <- liftIO $ sendYield sv winfo (ChildYield a)
|
||||
return $ if res then Continue else Suspend
|
||||
|
||||
-- XXX in general we would like to yield "n" elements from a single stream
|
||||
-- before moving on to the next. Single element granularity could be too
|
||||
-- expensive in certain cases. Similarly, we can use time limit for
|
||||
-- yielding.
|
||||
yieldk a r = do
|
||||
res <- liftIO $ sendYield sv winfo (ChildYield a)
|
||||
if res
|
||||
then foldStreamShared st yieldk single (return Continue) r
|
||||
else liftIO $ do
|
||||
enqueueFIFO sv q r
|
||||
return Suspend
|
||||
liftIO $ enqueueFIFO sv q r
|
||||
return $ if res then Continue else Suspend
|
||||
|
||||
{-# INLINE workLoopFIFOLimited #-}
|
||||
workLoopFIFOLimited
|
||||
@ -273,12 +274,12 @@ workLoopFIFOLimited q st sv winfo = run
|
||||
|
||||
yieldk a r = do
|
||||
res <- liftIO $ sendYield sv winfo (ChildYield a)
|
||||
liftIO $ enqueueFIFO sv q r
|
||||
yieldLimitOk <- liftIO $ decrementYieldLimit sv
|
||||
if res && yieldLimitOk
|
||||
then foldStreamShared st yieldk single incrContinue r
|
||||
then return Continue
|
||||
else liftIO $ do
|
||||
incrementYieldLimit sv
|
||||
enqueueFIFO sv q r
|
||||
return Suspend
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user