You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Capture and save state of the thread when suspending #369
When composing multiple streams using concurrent combinators like async, ahead or parallel we stop a thread midway in the stream if we find that the buffer is full. When we resume the stream later we start using a fresh monadic state from the SVar (svarMrun), at this point we have lost the state of the stream as it was when the stream stopped and we are now using incorrect state.
To resolve this we can either block the thread instead of stopping it or we can capture the state of the stream and store it along with the stream in the workqueue.
yieldk a r = do
res <- liftIO $ sendYield sv winfo (ChildYield a)
if res
then foldStreamShared st yieldk single run r
else liftIO $ do
enqueueLIFO sv q r
sendStop sv winfo
The sendStop case loses the state of the monad and we start using fresh state later.
The easiest idea is to captureMonadState and save RunInIO while enqueuing, with the stream itself. We might not need to save RunInIO in the SVar if this is followed, as every stream in the work queue will be associated with a RunInIO. There is probably a better solution, need to think about it.
Activity
harendra-kumar commentedon Jan 15, 2020
For example, in
workLoopLIFO:The
sendStopcase loses the state of the monad and we start using fresh state later.adithyaov commentedon Jul 4, 2020
The easiest idea is to
captureMonadStateand saveRunInIOwhile enqueuing, with the stream itself. We might not need to saveRunInIOin theSVarif this is followed, as every stream in the work queue will be associated with aRunInIO. There is probably a better solution, need to think about it.