Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mapPipelinedJob #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RahimovIR
Copy link
Contributor

mapPipelinedJob hangs when processing all incoming jobs is faster than closing <- true

also fixed the test

Copy link
Contributor

@Szer Szer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, as I understand there is race condition.

Let's say there is one-element stream which we pipelining to synchronous Job which returns immediately.

It means that this code will start closing the stream

Job.tryIn 
        (xs |> iterJob (Ch.give inCh))
        (fun () -> closing <- true; Job.unit() )
       ...

And also loop() will start to listen to it's Alt.choose cases.
In case closing hasn't been settled to true YET, our loop will stuck on such cases

outCh // won't be satisfied, as all workers are done already
inCh // won't be satisfied, as stream has iterated
Alt.never() // has been picked because `if closing && usage = 0` returned false

So yes, adding closeCh instead of boolean flag, will help with that.

@@ -530,17 +530,17 @@ module Stream =
mapJob x2yJ xs
else
delay <| fun () ->
let inCh, outCh = Ch(), Ch()
let inCh, outCh, closeCh = Ch(), Ch(), Ch()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be IVar for closing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it, but a little later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants