-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
sync: add mpsc::Sender::closed
future
#2840
sync: add mpsc::Sender::closed
future
#2840
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Left some comments.
tokio/src/sync/mpsc/chan.rs
Outdated
notify_rx_closed: Notify, | ||
|
||
/// Indicates whether the receiver has been dropped | ||
rx_closed: AtomicBool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to use a new bool here. The rx closed state is tracked by the semaphore.
Thanks, I addressed the comments. The loom tests will be failing until #2839 is merged. |
14379ba
to
9716c82
Compare
Not sure why CI fails, tests pass locally |
I restarted CI. |
Fixes: tokio-rs#2800 Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
9716c82
to
19bfab1
Compare
Signed-off-by: Zahari Dichev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
Motivation
Adding closed future, makes it possible to select over closed and some other work, so that the task is woken when the channel is closed and can proactively cancel itself.
Solution
Added a mpsc::Sender::closed future that will become ready when the receiver is closed