-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Documentation of watch::Sender implies that channel is closed forever when all receivers are dropped #4957
Comments
Well, if you want to be precise, your suggestion implies that it cannot ever be closed once a sender has been created. |
Whether it can be closed or not depends on the meaning of the word, I would say. You may say it can be "closed", but then it can be "reopened". My problem is that it's unclear how "the channel has been closed" is to be interpreted in English. It could be interpreted as "the channel was closed at some point in past" or as "the channel has been closed and is still in closed state". It's somewhat ambiguous due to different possible interpretations of the perfect tense, I would say. Hence I would suggest clarifying it. |
I mean, I agree that we should clarify it. |
Perhaps it should also be clarified what "failing" means (i.e. just returning |
Current documentation of `sync::watch::Sender::send` may be intepreted as the method failing if at some point in past the channel has been closed because every receiver has been dropped. This isn't true, however, as the channel could have been reopened by using `sync::watch::Sender::subscribe`. This fix clarifies the behavior. Moreover, it is noted that on failure, the value isn't made available to future subscribers (but returned as part of the `SendError`). Fixes tokio-rs#4957.
sync: doc of watch::Sender::send improved Current documentation of `sync::watch::Sender::send` may be intepreted as the method failing if at some point in past the channel has been closed because every receiver has been dropped. This isn't true, however, as the channel could have been reopened by using `sync::watch::Sender::subscribe`. This fix clarifies the behavior. Moreover, it is noted that on failure, the value isn't made available to future subscribers (but returned as part of the `SendError`), and that the other send methods (`send_if_modified`, `send_modify`, or `send_replace`) can be used to always make a new value available for future receivers, even if no receiver currently exists. Fixes tokio-rs#4957.
Current documentation of `sync::watch::Sender::send` may be intepreted as the method failing if at some point in past the channel has been closed because every receiver has been dropped. This isn't true, however, as the channel could have been reopened by using `sync::watch::Sender::subscribe`. This fix clarifies the behavior. Moreover, it is noted that on failure, the value isn't made available to future subscribers (but returned as part of the `SendError`). Fixes #4957.
Version
1.20.1
Platform
FreeBSD titanium 13.1-RELEASE-p1 FreeBSD 13.1-RELEASE-p1 GENERIC amd64
Description
Documentation of
tokio::sync::watch::Sender
says:This may be interpreted as the method failing if at some point in past the channel has been closed because every receiver has been dropped. This isn't true, however, as the following code demonstrates:
Perhaps it would be better if it read something like:
The text was updated successfully, but these errors were encountered: