From de46ae306560daf1a652b68d34d3d61113e7519a Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Sat, 4 Jun 2022 09:48:28 +0200 Subject: [PATCH] sync: add warning for watch in non-Send futures --- tokio/src/sync/watch.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tokio/src/sync/watch.rs b/tokio/src/sync/watch.rs index 184ba4b6041..7de4ebc0351 100644 --- a/tokio/src/sync/watch.rs +++ b/tokio/src/sync/watch.rs @@ -91,7 +91,9 @@ pub struct Sender { /// /// 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 -/// to keep the borrow 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. /// /// The priority policy of the lock is dependent on the underlying lock /// implementation, and this type does not guarantee that any particular policy @@ -301,7 +303,9 @@ impl Receiver { /// /// Outstanding borrows hold a read lock. This means that long lived borrows /// could cause the send half to block. It is recommended to keep the borrow - /// as short lived as possible. + /// 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. /// /// The priority policy of the lock is dependent on the underlying lock /// implementation, and this type does not guarantee that any particular policy @@ -344,7 +348,9 @@ impl Receiver { /// /// Outstanding borrows hold a read lock. This means that long lived borrows /// could cause the send half to block. It is recommended to keep the borrow - /// as short lived as possible. + /// 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. /// /// The priority policy of the lock is dependent on the underlying lock /// implementation, and this type does not guarantee that any particular policy