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

#554 in Concurrency

Download history 2858/week @ 2024-07-22 2259/week @ 2024-07-29 2269/week @ 2024-08-05 2393/week @ 2024-08-12 2443/week @ 2024-08-19 2646/week @ 2024-08-26 2905/week @ 2024-09-02 3049/week @ 2024-09-09 2592/week @ 2024-09-16 2464/week @ 2024-09-23 2646/week @ 2024-09-30 2708/week @ 2024-10-07 3079/week @ 2024-10-14 3008/week @ 2024-10-21 2674/week @ 2024-10-28 2491/week @ 2024-11-04

11,395 downloads per month
Used in 43 crates (27 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