Expand description
Lock-free queues.
§Examples
§Bounded SPSC
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();
}
Modules§
Enums§
- Consume
Error - Indicates the reason a
consume
operation could not return an item. - Produce
Error - Indicates the reason a
produce
operation rejected an item.