Crates.io | npnc |
lib.rs | npnc |
version | 0.2.1 |
source | src |
created_at | 2017-03-25 02:21:42.333637 |
updated_at | 2018-08-15 01:57:34.727932 |
description | Lock-free queues. |
homepage | |
repository | https://github.com/KyleMayes/npnc |
max_upload_size | |
id | 9143 |
size | 58,327 |
Lock-free queues.
Supported on the stable, beta, and nightly Rust channels.
Released under the Apache License 2.0.
extern crate npnc;
use std::thread;
use npnc::bounded::spsc;
fn main() {
let (producer, consumer) = spsc::channel(64);
// Producer
let b = thread::spawn(move || {
for index in 0..32 {
producer.produce(index).unwrap();
}
});
// Consumer
let a = thread::spawn(move || {
loop {
if let Ok(item) = consumer.consume() {
println!("{}", item);
if item == 31 {
break;
}
}
}
});
a.join().unwrap();
b.join().unwrap();
}