sync: add sender_weak_count and sender_strong_count for Receiver#6661
sync: add sender_weak_count and sender_strong_count for Receiver#6661wathenjiang merged 2 commits intotokio-rs:masterfrom
Conversation
0xPoe
left a comment
There was a problem hiding this comment.
🔢 Self-check (PR reviewed by myself and ready for feedback.)
| } | ||
|
|
||
| pub(super) fn weak_count(&self) -> usize { | ||
| self.inner.tx_weak_count.load(Relaxed) |
There was a problem hiding this comment.
Why Relaxed here? Wouldn't Acquire be appropriate?
(I am curious, not saying you're wrong)
There was a problem hiding this comment.
It looks like this is just mirroring the orderings on the equivalent sender methods. I don't think it really matters.
There was a problem hiding this comment.
The main difference between them as I understand it is that with tx_weak_count, it's simply a counter. So it doesn't matter what order it's in.
But with tx_count we rely on it to decide whether to close the channel or not, in addition to counting the number, and it's more of a synchronized operation, where we have to make sure that there is a guaranteed ordering of operations on it between threads.
I'm not sure if I'm right about this, I could be completely wrong 😆
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
cace970 to
954858c
Compare
Motivation
close #6653
Solution
Added
sender_weak_countandsender_strong_countfor Receiver and UnboundedReceiver.