#channel #broadcast #lock-free

bus

A lock-free, bounded, single-producer, multi-consumer, broadcast channel

19 stable releases

✓ Uses Rust 2018 edition

2.2.3 Mar 3, 2020
2.2.2 Jun 28, 2019
2.2.1 Mar 8, 2019
2.0.1 Dec 4, 2018
0.2.1 Jun 3, 2016

#42 in Concurrency

Download history 240/week @ 2019-12-02 230/week @ 2019-12-09 258/week @ 2019-12-16 142/week @ 2019-12-23 112/week @ 2019-12-30 281/week @ 2020-01-06 281/week @ 2020-01-13 307/week @ 2020-01-20 183/week @ 2020-01-27 218/week @ 2020-02-03 154/week @ 2020-02-10 216/week @ 2020-02-17 287/week @ 2020-02-24 438/week @ 2020-03-02 389/week @ 2020-03-09 364/week @ 2020-03-16

949 downloads per month
Used in 12 crates

MIT/Apache

36KB
335 lines

bus

Crates.io Documentation Build Status Codecov

Bus provides a lock-free, bounded, single-producer, multi-consumer, broadcast channel.

It uses a circular buffer and atomic instructions to implement a lock-free single-producer, multi-consumer channel. The interface is similar to that of the std::sync::mpsc channels, except that multiple consumers (readers of the channel) can be produced, whereas only a single sender can exist. Furthermore, in contrast to most multi-consumer FIFO queues, bus is broadcast; every send goes to every consumer.

I haven't seen this particular implementation in literature (some extra bookkeeping is necessary to allow multiple consumers), but a lot of related reading can be found in Ross Bencina's blog post "Some notes on lock-free and wait-free algorithms".

See the documentation for usage examples.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~635KB
~11K SLoC