Crate spmc [] [src]

SPMC

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

Example

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

Structs

Receiver

The receiving side of a SPMC channel.

RecvError

An error returned from the recv function on a Receiver.

SendError

An error returned from the send function on channels.

Sender

The Sending side of a SPMC channel.

Enums

TryRecvError

This enumeration is the list of the possible reasons that try_recv could not return data when called.

Functions

channel

Create a new SPMC channel.