-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
formalize waiting on multiple conditions #6563
Comments
An alternative would be AndCondition can be replaced directly by NotCondition is kind of interesting. It seems that to implement it, you'd need an extra Bool, and a task that waits for the condition and flips the Bool flag if it ever happens. However this does not work, since (1) notify will not necessarily notify all waiters, and (2) some other task might run before the flag-flipping task. This is just the same familiar race condition you get if you ever try to ask whether a condition happened (or if a RemoteRef has a value, etc.). If you want to know about a condition, you have to wait for it. So I'm not sure NotCondition is viable. |
since our condition variables are edge-triggered,
|
You're right, we'd need |
From an API perspective, using the boolean operators seems preferable to the macros. |
I think the bottom line is that this has to be based on |
Would it be reasonable to have |
after further contemplation, I think the only reasonable implementation for the current design (of edge-triggering) is |
I feel |
In #12042, there was general support for taking inspiration from Go's |
agreed, this really needs to be a Channel / level-triggered condition queue to avoid missing events |
We now have waitany and waitall for Tasks (and could be extended to other Events) |
in poll_fd, we see one pattern for waiting on multiple conditions, I propose the following simplification based upon chaining of Condition variables:
=> returns when either
cond1
has occurred, or (bothcond2
andcond3
have occurred, butcond4
has not occurred)pseudo implementation:
The text was updated successfully, but these errors were encountered: