Conqueue is yet another multi-producer, single-consumer queue (MPSC) for the Rust programming language.
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);
}
- Fix a major issue with
Sync
,Send
trait bounds forQueueSender
,QueueReceiver
, thanks to @JOE1994
- 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
- Republish to fix README.md on Crates.io
- Items that are pushed into a queue are now dropped if there is no receiver
- Senders should be
Send
- Initial release. Likely not production ready.
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:
- Edit
Cargo.toml
, bumping the version as appropriate. - Edit
README.md
, adding an entry to the Release Notes, and updating the TOML snippet's version. - Commit these changes and push them to
master
. - Create and push a tag that starts with "v" -- e.g. "v0.2.0"
This code is largely based on majek's implementation of Michael-Scott queue. You can find the code here and a blog post here.
Conqueue is provided under the MIT license.