Expand description
Multi-producer, multi-consumer FIFO queue communication primitives.
This module is extension of std::sync::mpsc, almost has same API
with it.
Differences are:
- A struct
SharedReceiveris defined. This is clone-able struct (multi-consumer). - A function
shared_channelcorresponding to functionchannelis defined.shared_channelreturns a(Sender, SharedReceiver)tuple instead of(Sender, Receiver)tuple.Senderis a struct that defined atstd::sync::mpsc. - A function
shared_sync_channelcorresponding to functionsync_channelis also defined. - Some feature of
std::sync::mpscis not implemented yet, for examplerecv_timeout.
§Example
Simple usage:
let (tx, rx) = shared_channel();
for i in 0..10 {
let rx = rx.clone();
thread::spawn(move || println!("{}", rx.recv().unwrap()));
}
for i in 0..10 {
tx.send(i).unwrap();
}More examples, see examples directory.
Structs§
- Iter
- Shared
Receiver - The clone-able
td::sync::mpsc::Receiver.