Skip to content

Commit 45f24f1

Browse files
authored
sync: add warning for watch in non-Send futures (#4741)
1 parent b51aa8f commit 45f24f1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tokio/src/sync/watch.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ pub struct Sender<T> {
9191
///
9292
/// Outstanding borrows hold a read lock on the inner value. This means that
9393
/// long lived borrows could cause the produce half to block. It is recommended
94-
/// to keep the borrow as short lived as possible.
94+
/// to keep the borrow as short lived as possible. Additionally, if you are
95+
/// running in an environment that allows `!Send` futures, you must ensure that
96+
/// the returned `Ref` type is never held alive across an `.await` point.
9597
///
9698
/// The priority policy of the lock is dependent on the underlying lock
9799
/// implementation, and this type does not guarantee that any particular policy
@@ -301,7 +303,9 @@ impl<T> Receiver<T> {
301303
///
302304
/// Outstanding borrows hold a read lock. This means that long lived borrows
303305
/// could cause the send half to block. It is recommended to keep the borrow
304-
/// as short lived as possible.
306+
/// as short lived as possible. Additionally, if you are running in an
307+
/// environment that allows `!Send` futures, you must ensure that the
308+
/// returned `Ref` type is never held alive across an `.await` point.
305309
///
306310
/// The priority policy of the lock is dependent on the underlying lock
307311
/// implementation, and this type does not guarantee that any particular policy
@@ -344,7 +348,9 @@ impl<T> Receiver<T> {
344348
///
345349
/// Outstanding borrows hold a read lock. This means that long lived borrows
346350
/// could cause the send half to block. It is recommended to keep the borrow
347-
/// as short lived as possible.
351+
/// as short lived as possible. Additionally, if you are running in an
352+
/// environment that allows `!Send` futures, you must ensure that the
353+
/// returned `Ref` type is never held alive across an `.await` point.
348354
///
349355
/// The priority policy of the lock is dependent on the underlying lock
350356
/// implementation, and this type does not guarantee that any particular policy

0 commit comments

Comments
 (0)