Skip to content

Fix document on watch #6507

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

Closed
wants to merge 1 commit into from
Closed

Fix document on watch #6507

wants to merge 1 commit into from

Conversation

takassh
Copy link

@takassh takassh commented Apr 22, 2024

Motivation

tokio::sync::watch should be a single-producer, multi-consumer channel afaik.
Actually, it can't be cloned.
So the current documentation may lead misunderstanding.

Solution

Fixed documentation

@github-actions github-actions bot added the R-loom-sync Run loom sync tests on this PR label Apr 22, 2024
@mox692
Copy link
Member

mox692 commented Apr 22, 2024

Thanks for the PR.

Clone of watch::Sender was introduced in this PR, and that change was shipped in the latest v1.37.0 release.

If you are not using v1.37.0 tokio, then you probably cannot use Sender's Clone.

@takassh
Copy link
Author

takassh commented Apr 22, 2024

@mox692
Ah thank you!
then this document may be wrong?
https://tokio.rs/tokio/tutorial/channels#tokios-channel-primitives

which says watch: single-producer, multi-consumer. Many values can be sent, but no history is kept. Receivers only see the most recent value.

Can I fix it?

@mox692
Copy link
Member

mox692 commented Apr 22, 2024

Thanks, that correction would be helpful.

@takassh
Copy link
Author

takassh commented Apr 22, 2024

Thanks for the quick response!
let me close this.

@takassh takassh closed this Apr 22, 2024
@Darksonn Darksonn added T-docs Topic: documentation A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Apr 22, 2024
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 M-sync Module: tokio/sync R-loom-sync Run loom sync tests on this PR T-docs Topic: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants