We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
watch::Sender::same_channel
1 parent 39cf6bb commit 3bf4f93Copy full SHA for 3bf4f93
tokio/src/sync/watch.rs
@@ -1324,6 +1324,22 @@ impl<T> Sender<T> {
1324
pub fn receiver_count(&self) -> usize {
1325
self.shared.ref_count_rx.load(Relaxed)
1326
}
1327
+
1328
+ /// Returns `true` if senders belong to the same channel.
1329
+ ///
1330
+ /// # Examples
1331
1332
+ /// ```
1333
+ /// let (tx, rx) = tokio::sync::watch::channel(true);
1334
+ /// let tx2 = tx.clone();
1335
+ /// assert!(tx.same_channel(&tx2));
1336
1337
+ /// let (tx3, rx3) = tokio::sync::watch::channel(true);
1338
+ /// assert!(!tx3.same_channel(&tx2));
1339
1340
+ pub fn same_channel(&self, other: &Self) -> bool {
1341
+ Arc::ptr_eq(&self.shared, &other.shared)
1342
+ }
1343
1344
1345
impl<T> Drop for Sender<T> {
0 commit comments