-
Notifications
You must be signed in to change notification settings - Fork 2
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
withBuffer should kill the other thread when one completes #1
Comments
Hmmm, I see what you mean. I suppose I was thinking more of input being exhausted rather than output not wanting any more input. I think what needs to happen is that the two |
Turns out I'm not sure if it's possible in the general case for I think the problem here is the usage of I think what you should do is to use The only other approach I can think of is that if you try and write to a basket that's already sealed it throws an exception; since it's possible, however, for the continuation to immediately exit before you recursively try to write to it I don't think that's viable. |
Can't it just throw an exception to the thread? It's obviously a bit cleaner if you use |
It might be the old "needs one in the chamber problem":
|
withBuffer
creates two threads - one to produce values and one to consume values. They communicate with a "seal" which starts empty, and when one thread finishes it signals that the work is done. The other thread notices the seal has been written to and stops what it is doing. However, this only works if the threads are blocked on activities relating to the basket. If they are actually blocked on some IO, they will never be terminated, and hence the wholewithBuffer
never terminates.In my project, I have a producer that reads from a
Socket
, and the consumer readsBinary
serialized values from connections to this socket:After all clients are done sending data, this won't terminate, because the
receive
action just gets stuck inaccept
.I think
withBuffer
should be in charge of killing the reader or writer. Does this make sense?The text was updated successfully, but these errors were encountered: