async-broadcast
An async multi-producer multi-consumer broadcast channel, where each consumer gets a clone of every
message sent on the channel. For obvious reasons, the channel can only be used to broadcast types
that implement Clone
.
A channel has the Sender
and Receiver
side. Both sides are cloneable and can be shared
among multiple threads.
When all Sender
s or all Receiver
s are dropped, the channel becomes closed. When a channel is
closed, no more messages can be sent, but remaining messages can still be received.
The channel can also be closed manually by calling Sender::close()
or
Receiver::close()
.
Difference with async-channel
This crate is similar to async-channel
in that they both provide an MPMC channel but the main
difference being that in async-channel
, each message sent on the channel is only received by one
of the receivers. async-broadcast
on the other hand, delivers each message to every receiver
(IOW broadcast) by cloning it for each receiver.
Examples
use ;
use ;
block_on
Safety
This crate uses #![deny(unsafe_code)]
to ensure everything is implemented in
100% Safe Rust.
Contributing
Want to join us? Check out our "Contributing" guide and take a look at some of these issues: