Capture the inner monad state and associate it with the work#583
Capture the inner monad state and associate it with the work#583harendra-kumar merged 4 commits intomasterfrom
Conversation
|
src/Streamly/Internal/Data/SVar.hs
Outdated
| , Ord | ||
| ) | ||
|
|
||
| type StreamWR t m a = Either (RunInIO m, t m a) (t m a) |
There was a problem hiding this comment.
Instead of using an Either type we can just use the tuple (RunInIO m, t m a), for the Right case of the Either the RunInIO state will be the initial state i.e. svarMrun.
There was a problem hiding this comment.
Yeah, that was the initial plan, that way we can remove svarMrun from the SVar as well.
| -- Use mrun here instead of the fold | ||
| else do | ||
| res <- liftIO $ runin (runStreamWithYieldLimit True seqNo r) | ||
| restoreM res |
There was a problem hiding this comment.
Instead of using runin, restoreM here we can use it inside runStreamWithYieldLimit. If we remove the Either type these two cases (Right/Left) will just become the second case.
There was a problem hiding this comment.
I take that back, runStreamWithYieldLimit is recursive, so its better done here.
| else liftIO $ do | ||
| else do | ||
| runInIO <- captureMonadState | ||
| -- XXX we also need to save the monadic state here |
There was a problem hiding this comment.
We can remove this comment now.
8e3b603 to
743faac
Compare
| liftIO (incrementYieldLimit sv) | ||
| nextHeap seqNo | ||
| -- Shouldn't we be using mrun here? | ||
| -- Use mrun in loopHeap instead |
There was a problem hiding this comment.
We can remove these comments.
| else liftIO $ do | ||
| else do | ||
| runInIO <- captureMonadState | ||
| -- XXX we also need to save the monadic state here |
src/Streamly/Internal/Data/SVar.hs
Outdated
| , Ord | ||
| ) | ||
|
|
||
| type StreamWR t m a = (RunInIO m, t m a) |
There was a problem hiding this comment.
I like to use the tuple directly instead of using a type indirection especially if the type is not very complicated. It saves one indirection for the reader of the code.
c398f27 to
99f2dab
Compare
|
@harendra-kumar Please review & merge this once the CI passes. |
harendra-kumar
left a comment
There was a problem hiding this comment.
- Update the changelog, describing the bug fix
- Can you move the test commit before the fix commits so that I can verify that the test fails before the fix and passes after the fix.
- Issue#369 - Preservation of monadic state across threads
|
I ran the benchmarks, there aren't significant changes. Merging this. |
Uh oh!
There was an error while loading. Please reload this page.