diff --git a/tokio/src/sync/mpsc/bounded.rs b/tokio/src/sync/mpsc/bounded.rs index 9a1c0ee79e5..beda7fe1bf4 100644 --- a/tokio/src/sync/mpsc/bounded.rs +++ b/tokio/src/sync/mpsc/bounded.rs @@ -713,13 +713,13 @@ impl Receiver { } /// Returns the number of [`Sender`] handles. - pub fn strong_count(&self) -> usize { - self.chan.strong_count() + pub fn sender_strong_count(&self) -> usize { + self.chan.sender_strong_count() } /// Returns the number of [`WeakSender`] handles. - pub fn weak_count(&self) -> usize { - self.chan.weak_count() + pub fn sender_weak_count(&self) -> usize { + self.chan.sender_weak_count() } } diff --git a/tokio/src/sync/mpsc/chan.rs b/tokio/src/sync/mpsc/chan.rs index 796b0d7aa39..4006aa2b746 100644 --- a/tokio/src/sync/mpsc/chan.rs +++ b/tokio/src/sync/mpsc/chan.rs @@ -470,11 +470,11 @@ impl Rx { &self.inner.semaphore } - pub(super) fn strong_count(&self) -> usize { + pub(super) fn sender_strong_count(&self) -> usize { self.inner.tx_count.load(Acquire) } - pub(super) fn weak_count(&self) -> usize { + pub(super) fn sender_weak_count(&self) -> usize { self.inner.tx_weak_count.load(Relaxed) } } diff --git a/tokio/src/sync/mpsc/unbounded.rs b/tokio/src/sync/mpsc/unbounded.rs index de934e3e090..47e1b6c7c77 100644 --- a/tokio/src/sync/mpsc/unbounded.rs +++ b/tokio/src/sync/mpsc/unbounded.rs @@ -500,13 +500,13 @@ impl UnboundedReceiver { } /// Returns the number of [`UnboundedSender`] handles. - pub fn strong_count(&self) -> usize { - self.chan.strong_count() + pub fn sender_strong_count(&self) -> usize { + self.chan.sender_strong_count() } /// Returns the number of [`WeakUnboundedSender`] handles. - pub fn weak_count(&self) -> usize { - self.chan.weak_count() + pub fn sender_weak_count(&self) -> usize { + self.chan.sender_weak_count() } } diff --git a/tokio/tests/sync_mpsc_weak.rs b/tokio/tests/sync_mpsc_weak.rs index 5d334dda33c..fba0fe4e33a 100644 --- a/tokio/tests/sync_mpsc_weak.rs +++ b/tokio/tests/sync_mpsc_weak.rs @@ -538,7 +538,7 @@ async fn sender_strong_count_when_cloned() { assert_eq!(tx.strong_count(), 2); assert_eq!(tx2.strong_count(), 2); - assert_eq!(rx.strong_count(), 2); + assert_eq!(rx.sender_strong_count(), 2); } #[tokio::test] @@ -560,7 +560,7 @@ async fn sender_strong_count_when_dropped() { drop(tx2); assert_eq!(tx.strong_count(), 1); - assert_eq!(rx.strong_count(), 1); + assert_eq!(rx.sender_strong_count(), 1); } #[tokio::test] @@ -572,7 +572,7 @@ async fn sender_weak_count_when_dropped() { drop(weak); assert_eq!(tx.weak_count(), 0); - assert_eq!(rx.weak_count(), 0); + assert_eq!(rx.sender_weak_count(), 0); } #[tokio::test] @@ -588,24 +588,24 @@ async fn sender_strong_and_weak_conut() { assert_eq!(tx2.strong_count(), 2); assert_eq!(weak.strong_count(), 2); assert_eq!(weak2.strong_count(), 2); - assert_eq!(rx.strong_count(), 2); + assert_eq!(rx.sender_strong_count(), 2); assert_eq!(tx.weak_count(), 2); assert_eq!(tx2.weak_count(), 2); assert_eq!(weak.weak_count(), 2); assert_eq!(weak2.weak_count(), 2); - assert_eq!(rx.weak_count(), 2); + assert_eq!(rx.sender_weak_count(), 2); drop(tx2); drop(weak2); assert_eq!(tx.strong_count(), 1); assert_eq!(weak.strong_count(), 1); - assert_eq!(rx.strong_count(), 1); + assert_eq!(rx.sender_strong_count(), 1); assert_eq!(tx.weak_count(), 1); assert_eq!(weak.weak_count(), 1); - assert_eq!(rx.weak_count(), 1); + assert_eq!(rx.sender_weak_count(), 1); } #[tokio::test] @@ -616,7 +616,7 @@ async fn unbounded_sender_strong_count_when_cloned() { assert_eq!(tx.strong_count(), 2); assert_eq!(tx2.strong_count(), 2); - assert_eq!(rx.strong_count(), 2); + assert_eq!(rx.sender_strong_count(), 2); } #[tokio::test] @@ -627,7 +627,7 @@ async fn unbounded_sender_weak_count_when_downgraded() { assert_eq!(tx.weak_count(), 1); assert_eq!(weak.weak_count(), 1); - assert_eq!(rx.weak_count(), 1); + assert_eq!(rx.sender_weak_count(), 1); } #[tokio::test] @@ -639,7 +639,7 @@ async fn unbounded_sender_strong_count_when_dropped() { drop(tx2); assert_eq!(tx.strong_count(), 1); - assert_eq!(rx.strong_count(), 1); + assert_eq!(rx.sender_strong_count(), 1); } #[tokio::test] @@ -651,7 +651,7 @@ async fn unbounded_sender_weak_count_when_dropped() { drop(weak); assert_eq!(tx.weak_count(), 0); - assert_eq!(rx.weak_count(), 0); + assert_eq!(rx.sender_weak_count(), 0); } #[tokio::test] @@ -667,22 +667,22 @@ async fn unbounded_sender_strong_and_weak_conut() { assert_eq!(tx2.strong_count(), 2); assert_eq!(weak.strong_count(), 2); assert_eq!(weak2.strong_count(), 2); - assert_eq!(rx.strong_count(), 2); + assert_eq!(rx.sender_strong_count(), 2); assert_eq!(tx.weak_count(), 2); assert_eq!(tx2.weak_count(), 2); assert_eq!(weak.weak_count(), 2); assert_eq!(weak2.weak_count(), 2); - assert_eq!(rx.weak_count(), 2); + assert_eq!(rx.sender_weak_count(), 2); drop(tx2); drop(weak2); assert_eq!(tx.strong_count(), 1); assert_eq!(weak.strong_count(), 1); - assert_eq!(rx.strong_count(), 1); + assert_eq!(rx.sender_strong_count(), 1); assert_eq!(tx.weak_count(), 1); assert_eq!(weak.weak_count(), 1); - assert_eq!(rx.weak_count(), 1); + assert_eq!(rx.sender_weak_count(), 1); }