#queue #concurrent #mpsc #ms #channel

conqueue

Yet another multi-producer, single-consumer queue (MPSC)

6 releases (3 breaking)

0.4.0 Jan 24, 2021
0.3.0 Sep 3, 2019
0.2.1 Aug 29, 2019
0.1.1 Jul 31, 2019

#52 in Concurrency

Download history 1080/week @ 2021-07-02 2010/week @ 2021-07-09 928/week @ 2021-07-16 1941/week @ 2021-07-23 1714/week @ 2021-07-30 1749/week @ 2021-08-06 2159/week @ 2021-08-13 1872/week @ 2021-08-20 1291/week @ 2021-08-27 1403/week @ 2021-09-03 1495/week @ 2021-09-10 2881/week @ 2021-09-17 2735/week @ 2021-09-24 2682/week @ 2021-10-01 3447/week @ 2021-10-08 3300/week @ 2021-10-15

2,325 downloads per month
Used in 2 crates (via near-network)

MIT license

13KB
295 lines

Conqueue

Crates.io Crates.io

Conqueue is yet another multi-producer, single-consumer queue (MPSC) for the Rust programming language.

Getting Started

To get started, add the following to your Cargo.toml file:

[dependencies]
conqueue = "0.4.0"

Then, at the root of your crate:

extern crate conqueue

Finally, create a sender/receiver pair. The sender may be cloned to allow concurrent producers, and it is both Send and Sync. The receiver is Send so it may be moved to other threads.

let (tx1, mut rx) = conqueue::Queue::unbounded();
let tx2 = tx1.clone();

tx1.push(1);
tx2.push(2);

while let Some(value) = rx.pop() {
  println!("popped: {}", value);
}

Release Notes

0.4.0 - 2021-01-24

  • Fix a major issue with Sync, Send trait bounds for QueueSender, QueueReceiver, thanks to @JOE1994

0.3.0 - 2019-09-03

  • Use compare_exchange, allowing push with a single atomic instruction in certain circumstances
  • Fix a small memory leak when all related senders/receivers are dropped

0.2.1 - 2019-08-29

  • Republish to fix README.md on Crates.io

0.2.0 - 2019-08-29

  • Items that are pushed into a queue are now dropped if there is no receiver

0.1.1 - 2019-07-30

  • Senders should be Send

0.1.0 - 2019-07-30

  • Initial release. Likely not production ready.

Developer Notes

To run the tests, execute the following:

cargo test

To run a benchmark for the queue, execute the following:

cargo test --release -- --ignored --nocapture

To release the create, perform the following:

  1. Edit Cargo.toml, bumping the version as appropriate.
  2. Edit README.md, adding an entry to the Release Notes, and updating the TOML snippet's version.
  3. Commit these changes and push them to master.
  4. Create and push a tag that starts with "v" -- e.g. "v0.2.0"

Inspiration

This code is largely based on majek's implementation of Michael-Scott queue. You can find the code here and a blog post here.

License

Conqueue is provided under the MIT license.

No runtime deps