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

sync: add mpsc::Sender::closed future #2840

Merged
merged 6 commits into from
Sep 25, 2020

Conversation

zaharidichev
Copy link
Contributor

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

@Darksonn Darksonn added A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-sync Module: tokio/sync labels Sep 17, 2020
@carllerche carllerche requested a review from hawkw September 21, 2020 15:57
Copy link
Member

@carllerche carllerche left a 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.

notify_rx_closed: Notify,

/// Indicates whether the receiver has been dropped
rx_closed: AtomicBool,
Copy link
Member

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.

@zaharidichev
Copy link
Contributor Author

Thanks, I addressed the comments. The loom tests will be failing until #2839 is merged.

@zaharidichev zaharidichev force-pushed the zd/add-sender-closed-future branch 4 times, most recently from 14379ba to 9716c82 Compare September 24, 2020 09:36
@zaharidichev
Copy link
Contributor Author

Not sure why CI fails, tests pass locally

@Darksonn
Copy link
Contributor

I restarted CI.

@zaharidichev zaharidichev force-pushed the zd/add-sender-closed-future branch from 9716c82 to 19bfab1 Compare September 25, 2020 06:30
Signed-off-by: Zahari Dichev <[email protected]>
Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@carllerche carllerche merged commit 55d932a into tokio-rs:master Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-sync Module: tokio/sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants