]> git.feebdaed.xyz Git - 0xmirror/tokio.git/commitdiff
sync: clarify the cancellation safety of `oneshot::Receiver` (#7780)
authorQi <add_sp@outlook.com>
Thu, 18 Dec 2025 11:21:59 +0000 (19:21 +0800)
committerGitHub <noreply@github.com>
Thu, 18 Dec 2025 11:21:59 +0000 (19:21 +0800)
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
tokio/src/sync/oneshot.rs

index c5857f65491902dc12922f3d918987c7ad38ec84..32e28844257e151c0763784dab2980b741dba029 100644 (file)
@@ -243,6 +243,13 @@ pub struct Sender<T> {
 ///
 /// [`Future`]: trait@std::future::Future
 ///
+/// # Cancellation safety
+///
+/// The `Receiver` is cancel safe. If it is used as the event in a
+/// [`tokio::select!`](crate::select) statement and some other branch
+/// completes first, it is guaranteed that no message was received on this
+/// channel.
+///
 /// # Examples
 ///
 /// ```