Implement simple atomic stream select#585
Open
dermesser wants to merge 5 commits intoocaml-multicore:mainfrom
Open
Implement simple atomic stream select#585dermesser wants to merge 5 commits intoocaml-multicore:mainfrom
dermesser wants to merge 5 commits intoocaml-multicore:mainfrom
Conversation
25a9d99 to
468126d
Compare
468126d to
11c0c6e
Compare
Author
|
I'm currently also trying to understand the 0-capacity stream mechanics, and hopefully will come up with a way to (ideally) select out of a mixed set of streams. |
talex5
reviewed
Jul 19, 2023
lib_eio/stream.ml
Outdated
| then ( | ||
| cancel_all (); | ||
| Mutex.unlock t.mutex; | ||
| enqueue (Ok (f (Queue.take t.items)))) |
Collaborator
There was a problem hiding this comment.
Another domain could still have set finished to true using a different stream by the time this runs.
(also, you can't use Queue.take after unlocking)
Author
There was a problem hiding this comment.
Apologies for missing this, it should have been obvious! Please take another look, it seemed not too difficult to fix.
Otherwise, `Stdlib.Effect.Continuation_already_resumed` will be raised.
Author
|
I've added a small benchmark (f733045) which helped fix two bugs (the two preceding commits). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
for #577, to supersede #578.
I want to emphasize that this change is based on my likely too superficial understanding of the library. It is likely that there exists a more elegant way to implement it.
Waitersmodule slightly, which is what I had hoped to avoid by using multiple fibers previously. The way I modified it makes sense for this kind of application, but it could be that there is a race condition or logical trap I overlooked.select_of_manydoes, but maybe it helps you while reviewing it :-)Lockingstreams are handled at the moment, with anassertin place to enforce this. Mostly for the reason that I've wanted to get an initial implementation going before trying to handle everything.Again, I'm not at all offended if a tighter implementation ends up replacing this PR, but my fingers were itching to try and implement it myself :-)