Module comm::mpsc[][src]

Multiple-producer, single-consumer (MPSC) channels.

MPSC channels can be dynamically allocated from a Switchboard:

use comm::Switchboard;
use futures::sink::SinkExt;
use futures::stream::StreamExt;
use tokio::net::UnixStream;

let switchboard = Switchboard::local()?;
let (tx, mut rx) = switchboard.mpsc();
tokio::spawn(async move {
    // Do work.
    let answer = 42;
    Ok::<_, comm::Error>(())
assert_eq!(, Some(42));

Unconnected senders are quite flexible. They implement Serialize and Deserialize so that they can be sent over the network to other processes, or Cloned and shared with other threads in the same process.

Receivers and connected senders are less flexible, but still implement Send and so can be freely sent between threads.



The receiving end of an MPSC channel.


The transmission end of an MPSC channel.