4 releases

Uses old Rust 2015

0.2.1 Aug 15, 2018
0.2.0 Apr 14, 2017
0.1.1 Mar 25, 2017
0.1.0 Mar 25, 2017

#729 in Concurrency

Download history 12/week @ 2024-02-19 19/week @ 2024-02-26 9/week @ 2024-03-04 17/week @ 2024-03-11 6/week @ 2024-03-18 107/week @ 2024-04-01

132 downloads per month
Used in 3 crates

Apache-2.0

39KB
668 lines

npnc

crates.io docs.rs Travis CI

Lock-free queues.

Supported on the stable, beta, and nightly Rust channels.

Released under the Apache License 2.0.

Features

  • Bounded lock-free SPSC queue
  • Bounded lock-free MPMC queue
  • Unbounded lock-free SPSC queue
  • Unbounded lock-free MPMC queue

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

Dependencies

~9KB