tokio
tokio copied to clipboard
Get `mpsc::Sender` count on `mpsc::Receiver`
Context
I frequently work on designs where an mpsc channel "holds the app together", for example a simple TCP server that connects multiple clients with a shared resource. When I want to see how my system performs (under load etc.) I can already see many things like the number of enqueued messages.
In some cases, I also want to see the Number of existing Senders for a receiver.
Solution
I'd love it if one could call a method on mpsc::Receiver to get the number of mpsc::Senders.
Alternative
Arc<AtomicUsize> shared by senders? The advantage is that senders could see the sender count too, for whatever use.
We already have weak_count and strong_count methods on Sender. I think it makes sense to add them to the Receiver as well.
I will try to add it!