#队列 #有界 #分析 #bbq #生产者 #交换 #消费者

nightly bbq-rs

基于块的有限队列,用于数据交换和分析

2 个版本

0.1.1 2023 年 2 月 18 日
0.1.0 2023 年 2 月 18 日

#1096并发

自定义许可协议

22KB
513

BBQ:基于块的有限队列,用于数据交换和分析

这是一个支持多个生产者和多个消费者的并发队列。它基于论文 "BBQ:基于块的有限队列,用于数据交换和分析" 实现,可以使用如下方式

用法

bbq-rs 添加到您的 Cargo.toml 依赖项中

[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());  
        });  
    }
}

依赖项

~130KB