Crate shared_channel

source ·
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 SharedReceiver is defined. This is clone-able struct (multi-consumer).
  • A function shared_channel corresponding to function channel is defined. shared_channel returns a (Sender, SharedReceiver) tuple instead of (Sender, Receiver) tuple. Sender is a struct that defined at std::sync::mpsc.
  • A function shared_sync_channel corresponding to function sync_channel is also defined.
  • Some feature of std::sync::mpsc is not implemented yet, for example recv_timeout.


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 {

More examples, see examples directory.


The clone-able td::sync::mpsc::Receiver.