-
I'm a Rust and Tokio newbie, so I apologise if this is a silly question. I've been playing around with broadcast channels, and trying trying to find a way to connect spawned tasks together so they can send messages to one another. I find that I can clone a broadcast::Sender, but not a broadcast::Receiver. My understanding is that a broadcast channel can have multiple senders and receivers, so presumably it should be possible to clone both... What am I missing? Here's my test code:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The receiver provides a method called Making a clone that has the same position as the one you're cloning isn't currently possible. There has been some work on implementing it, but it causes some issues with the current way that the channel is implemented. |
Beta Was this translation helpful? Give feedback.
The receiver provides a method called
resubscribe
that you can use for this. You can also callSender::subscribe
to create new receivers.Making a clone that has the same position as the one you're cloning isn't currently possible. There has been some work on implementing it, but it causes some issues with the current way that the channel is implemented.