-
-
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
Make sync::watch::Sender::subscribe
public
#3800
Conversation
Make the internal watch::Sender::subscribe method public. Also adds documentation.
Note: the I don't see why this was the case, maybe because it was only required in other code behind the feature? |
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!
tokio/src/sync/watch.rs
Outdated
/// Creates a new [`Receiver`] handle that will receive values sent **after** | ||
/// this call to `subscribe`. |
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.
/// Creates a new [`Receiver`] handle that will receive values sent **after** | |
/// this call to `subscribe`. | |
/// Creates a new [`Receiver`] handle that will receive values sent after | |
/// this call to `subscribe`. |
tokio/src/sync/watch.rs
Outdated
/// Creates a new [`Receiver`] handle that will receive values sent **after** | ||
/// this call to `subscribe`. | ||
/// | ||
/// # Examples |
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.
Can you add a note about how this method behaves if the channel is closed when you call it? And preferably also add a test for that behavior?
What's the status on this PR? |
I'll get to to it in the next few days - today or tomorrow hopefully. |
sync::watch::Sender::subscribe
public
Motivation
Unlike with
sync::broadcast::Sender
, thesync::watch::Sender::subscribe
method is currently not public.This means handing out new subscriptions means keeping around a redundant Receiver, which is pretty unergonomic.
I don't really see a reason why this is the case, since the data structuredoesn't seem to have any relevant restrictions.
This was also requested in #3757.
Solution
Make
watch::Sender::subscribe
public.Also adds a doc test.