1 unstable release

Uses old Rust 2015

0.3.0 Aug 16, 2019
0.2.3 Aug 15, 2019
0.2.2 Jun 26, 2017
0.2.1 May 7, 2016
0.1.0 Oct 7, 2015

#4 in #spmc

Download history 1020/week @ 2022-01-25 876/week @ 2022-02-01 1070/week @ 2022-02-08 904/week @ 2022-02-15 1119/week @ 2022-02-22 1047/week @ 2022-03-01 1264/week @ 2022-03-08 926/week @ 2022-03-15 1602/week @ 2022-03-22 1623/week @ 2022-03-29 1779/week @ 2022-04-05 1243/week @ 2022-04-12 1428/week @ 2022-04-19 1610/week @ 2022-04-26 1441/week @ 2022-05-03 1463/week @ 2022-05-10

6,130 downloads per month
Used in 16 crates (13 directly)

MIT/Apache

16KB
390 lines

spmc

Build Status crates.io

Single-Producer, Multiple-Consumer channel for Rust.

Documentation

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

SPMC

A single producer, multiple consumers. Commonly used to implement work-stealing.

Example

# use std::thread;
let (mut tx, rx) = spmc::channel();

let mut handles = Vec::new();
for n in 0..5 {
    let rx = rx.clone();
    handles.push(thread::spawn(move || {
        let msg = rx.recv().unwrap();
        println!("worker {} recvd: {}", n, msg);
    }));
}

for i in 0..5 {
    tx.send(i * 2).unwrap();
}

for handle in handles {
  handle.join().unwrap();
}

No runtime deps