sync: improve watch docs (#5261)

This commit is contained in:
Vitalii Kryvenko 2022-12-04 02:06:12 +02:00 committed by GitHub
parent 87510100ce
commit 00bf5ee8a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,10 +9,10 @@
//! # Usage //! # Usage
//! //!
//! [`channel`] returns a [`Sender`] / [`Receiver`] pair. These are the producer //! [`channel`] returns a [`Sender`] / [`Receiver`] pair. These are the producer
//! and sender halves of the channel. The channel is created with an initial //! and consumer halves of the channel. The channel is created with an initial
//! value. The **latest** value stored in the channel is accessed with //! value. The **latest** value stored in the channel is accessed with
//! [`Receiver::borrow()`]. Awaiting [`Receiver::changed()`] waits for a new //! [`Receiver::borrow()`]. Awaiting [`Receiver::changed()`] waits for a new
//! value to sent by the [`Sender`] half. //! value to be sent by the [`Sender`] half.
//! //!
//! # Examples //! # Examples
//! //!
@ -90,10 +90,11 @@ pub struct Sender<T> {
/// Returns a reference to the inner value. /// Returns a reference to the inner value.
/// ///
/// Outstanding borrows hold a read lock on the inner value. This means that /// Outstanding borrows hold a read lock on the inner value. This means that
/// long lived borrows could cause the produce half to block. It is recommended /// long-lived borrows could cause the producer half to block. It is recommended
/// to keep the borrow as short lived as possible. Additionally, if you are /// to keep the borrow as short-lived as possible. Additionally, if you are
/// running in an environment that allows `!Send` futures, you must ensure that /// running in an environment that allows `!Send` futures, you must ensure that
/// the returned `Ref` type is never held alive across an `.await` point. /// the returned `Ref` type is never held alive across an `.await` point,
/// otherwise, it can lead to a deadlock.
/// ///
/// The priority policy of the lock is dependent on the underlying lock /// The priority policy of the lock is dependent on the underlying lock
/// implementation, and this type does not guarantee that any particular policy /// implementation, and this type does not guarantee that any particular policy
@ -350,11 +351,12 @@ impl<T> Receiver<T> {
/// [`changed`] may return immediately even if you have already seen the /// [`changed`] may return immediately even if you have already seen the
/// value with a call to `borrow`. /// value with a call to `borrow`.
/// ///
/// Outstanding borrows hold a read lock. This means that long lived borrows /// Outstanding borrows hold a read lock on the inner value. This means that
/// could cause the send half to block. It is recommended to keep the borrow /// long-lived borrows could cause the producer half to block. It is recommended
/// as short lived as possible. Additionally, if you are running in an /// to keep the borrow as short-lived as possible. Additionally, if you are
/// environment that allows `!Send` futures, you must ensure that the /// running in an environment that allows `!Send` futures, you must ensure that
/// returned `Ref` type is never held alive across an `.await` point. /// the returned `Ref` type is never held alive across an `.await` point,
/// otherwise, it can lead to a deadlock.
/// ///
/// The priority policy of the lock is dependent on the underlying lock /// The priority policy of the lock is dependent on the underlying lock
/// implementation, and this type does not guarantee that any particular policy /// implementation, and this type does not guarantee that any particular policy
@ -401,11 +403,12 @@ impl<T> Receiver<T> {
/// will not return immediately until the [`Sender`] has modified the shared /// will not return immediately until the [`Sender`] has modified the shared
/// value again. /// value again.
/// ///
/// Outstanding borrows hold a read lock. This means that long lived borrows /// Outstanding borrows hold a read lock on the inner value. This means that
/// could cause the send half to block. It is recommended to keep the borrow /// long-lived borrows could cause the producer half to block. It is recommended
/// as short lived as possible. Additionally, if you are running in an /// to keep the borrow as short-lived as possible. Additionally, if you are
/// environment that allows `!Send` futures, you must ensure that the /// running in an environment that allows `!Send` futures, you must ensure that
/// returned `Ref` type is never held alive across an `.await` point. /// the returned `Ref` type is never held alive across an `.await` point,
/// otherwise, it can lead to a deadlock.
/// ///
/// The priority policy of the lock is dependent on the underlying lock /// The priority policy of the lock is dependent on the underlying lock
/// implementation, and this type does not guarantee that any particular policy /// implementation, and this type does not guarantee that any particular policy
@ -794,9 +797,12 @@ impl<T> Sender<T> {
/// Returns a reference to the most recently sent value /// Returns a reference to the most recently sent value
/// ///
/// Outstanding borrows hold a read lock. This means that long lived borrows /// Outstanding borrows hold a read lock on the inner value. This means that
/// could cause the send half to block. It is recommended to keep the borrow /// long-lived borrows could cause the producer half to block. It is recommended
/// as short lived as possible. /// to keep the borrow as short-lived as possible. Additionally, if you are
/// running in an environment that allows `!Send` futures, you must ensure that
/// the returned `Ref` type is never held alive across an `.await` point,
/// otherwise, it can lead to a deadlock.
/// ///
/// # Examples /// # Examples
/// ///