Skip to content

Commit

Permalink
refactor: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Jul 1, 2024
1 parent 4cf8228 commit 954858c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions tokio/src/sync/mpsc/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,13 @@ impl<T> Receiver<T> {
}

/// 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()
}
}

Expand Down
4 changes: 2 additions & 2 deletions tokio/src/sync/mpsc/chan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,11 @@ impl<T, S: Semaphore> Rx<T, S> {
&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)
}
}
Expand Down
8 changes: 4 additions & 4 deletions tokio/src/sync/mpsc/unbounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,13 @@ impl<T> UnboundedReceiver<T> {
}

/// 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()
}
}

Expand Down
30 changes: 15 additions & 15 deletions tokio/tests/sync_mpsc_weak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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);
}

0 comments on commit 954858c

Please sign in to comment.