Crates.io | bbq-rs |
lib.rs | bbq-rs |
version | 0.1.1 |
source | src |
created_at | 2023-02-18 13:43:17.557999 |
updated_at | 2023-02-18 15:32:02.238896 |
description | A Block-based Bounded Queue for Exchanging Data and Profiling |
homepage | |
repository | |
max_upload_size | |
id | 788222 |
size | 22,594 |
This is a concurrent queue that supports multiple producers and multiple consumers. It is implemented based on the paper "BBQ: A Block-based Bounded Queue for Exchanging Data and Profiling" and can be used as follows:
Add bbq-rs
to your Cargo.toml
dependencies:
[dependencies]
bbq-rs = "0.1.1"
use bbq_rs::Bbq;
use bbq_rs::BlockingQueue;
fn main() {
let queue = Bbq::new(100, 100).unwrap();
// Create four producer threads
for i in 0..4 {
let q = queue.clone();
std::thread::spawn(move || {
q.push(i);
});
// Create four consumer threads
for _ in 0..4 {
let q = queue.clone();
std::thread::spawn(move || {
println!("{}", q.pop().unwrap());
});
}
}