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
Download history 1836/week @ 2024-06-20 1995/week @ 2024-06-27 1771/week @ 2024-07-04 2351/week @ 2024-07-11 2795/week @ 2024-07-18 2506/week @ 2024-07-25 2079/week @ 2024-08-01 2651/week @ 2024-08-08 2075/week @ 2024-08-15 2742/week @ 2024-08-22 2450/week @ 2024-08-29 3364/week @ 2024-09-05 2892/week @ 2024-09-12 2502/week @ 2024-09-19 2411/week @ 2024-09-26 2267/week @ 2024-10-03

10,680 downloads per month
Used in 42 crates (26 directly)

MIT/Apache

17KB
390 lines

spmc

Build Status

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

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