Skip to content

Commit 5f3f5b0

Browse files
martin-gDarksonn
andauthored
sync: improve the docs of sync::watch (#7601)
Co-authored-by: Alice Ryhl <[email protected]>
1 parent 32a1acc commit 5f3f5b0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

tokio/src/sync/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@
278278
//!
279279
//! ## `watch` channel
280280
//!
281-
//! The [`watch` channel] supports sending **many** values from a **many**
282-
//! producer to **many** consumers. However, only the **most recent** value is
281+
//! The [`watch` channel] supports sending **many** values from **many**
282+
//! producers to **many** consumers. However, only the **most recent** value is
283283
//! stored in the channel. Consumers are notified when a new value is sent, but
284284
//! there is no guarantee that consumers will see **all** values.
285285
//!

tokio/src/sync/watch.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//! method is ready when a new, *unseen* value is sent via the [`Sender`] half.
3131
//!
3232
//! * [`Receiver::changed()`] returns `Ok(())` on receiving a new value, or
33-
//! `Err(`[`error::RecvError`]`)` if the [`Sender`] has been dropped.
33+
//! `Err(`[`error::RecvError`]`)` if all [`Sender`]s have been dropped.
3434
//! * If the current value is *unseen* when calling [`changed`], then
3535
//! [`changed`] will return immediately. If the current value is *seen*, then
3636
//! it will sleep until either a new message is sent via the [`Sender`] half,
@@ -90,7 +90,7 @@
9090
//! when all [`Receiver`] handles have been dropped. This indicates that there
9191
//! is no further interest in the values being produced and work can be stopped.
9292
//!
93-
//! The value in the channel will not be dropped until the sender and all
93+
//! The value in the channel will not be dropped until all senders and all
9494
//! receivers have been dropped.
9595
//!
9696
//! # Thread safety
@@ -391,7 +391,7 @@ mod state {
391391
/// Snapshot of the state. The first bit is used as the CLOSED bit.
392392
/// The remaining bits are used as the version.
393393
///
394-
/// The CLOSED bit tracks whether the Sender has been dropped. Dropping all
394+
/// The CLOSED bit tracks whether all senders have been dropped. Dropping all
395395
/// receivers does not set it.
396396
#[derive(Copy, Clone, Debug)]
397397
pub(super) struct StateSnapshot(usize);
@@ -670,7 +670,7 @@ impl<T> Receiver<T> {
670670
// Load the version from the state
671671
let state = self.shared.state.load();
672672
if state.is_closed() {
673-
// The sender has dropped.
673+
// All senders have dropped.
674674
return Err(error::RecvError(()));
675675
}
676676
let new_version = state.version();
@@ -706,10 +706,10 @@ impl<T> Receiver<T> {
706706
/// If the newest value in the channel has not yet been marked seen when
707707
/// this method is called, the method marks that value seen and returns
708708
/// immediately. If the newest value has already been marked seen, then the
709-
/// method sleeps until a new message is sent by the [`Sender`] connected to
710-
/// this `Receiver`, or until the [`Sender`] is dropped.
709+
/// method sleeps until a new message is sent by a [`Sender`] connected to
710+
/// this `Receiver`, or until all [`Sender`]s are dropped.
711711
///
712-
/// This method returns an error if and only if the [`Sender`] is dropped.
712+
/// This method returns an error if and only if all [`Sender`]s are dropped.
713713
///
714714
/// For more information, see
715715
/// [*Change notifications*](self#change-notifications) in the module-level documentation.
@@ -901,7 +901,7 @@ fn maybe_changed<T>(
901901
}
902902

903903
if state.is_closed() {
904-
// The sender has been dropped.
904+
// All senders have been dropped.
905905
return Some(Err(error::RecvError(())));
906906
}
907907

0 commit comments

Comments
 (0)