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

#234 in Concurrency

Download history 4516/week @ 2023-11-29 4719/week @ 2023-12-06 4772/week @ 2023-12-13 1796/week @ 2023-12-20 1692/week @ 2023-12-27 2828/week @ 2024-01-03 2624/week @ 2024-01-10 2111/week @ 2024-01-17 2495/week @ 2024-01-24 3954/week @ 2024-01-31 2948/week @ 2024-02-07 2169/week @ 2024-02-14 1929/week @ 2024-02-21 2012/week @ 2024-02-28 1741/week @ 2024-03-06 1570/week @ 2024-03-13

7,632 downloads per month
Used in 37 crates (22 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