-
-
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
Add method mpsc::Receiver::is_closed
#4638
Comments
Hi Nugine, Please can you expand on your use case/scenario where having this method would provide a better solution than the existing mechanism of calling Ian |
In general, I am ok with adding this assuming that it is easy to add. |
I need to check whether a command channel is closed before trying to reconnect to a remote server. |
@Darksonn Obviously from your comment you can't be certain, but would your assumption lean toward most likely it is easy to add? I'd love to contribute to Tokio, so maybe this a good starting point, or would you point me elsewhere? |
My guess is that it is easy, yes. You're welcome to submit a PR for this. You might also want to look in the help wanted tag for easy ones, though note that the older ones might be outdated. If you have questions on how to approach writing the PR, you can ask in our discord server (or here). |
As a use case, I have a trait that implements reader and writer functionality similar to For one implementation, it uses mpsc Sender and Receiver. It's easy to check if |
I would be interested in picking this up -- this change seems more than just adding a single method so will be reaching out to you folks on Discord. |
There's a use case for channels that wants to know up-front (before calling `recv` or `try_recv`)that there's a possibility of new messages coming in. Make it possible to check whether the channel is closed and empty, which implies that there will never be new messages on this channel. Fixes: tokio-rs#4638
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
Add a method to check whether the mpsc channel is closed from rx side.
mpsc::Receiver::is_closed
https://docs.rs/tokio/1.17.0/tokio/sync/mpsc/struct.Sender.html#method.is_closed
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: