futures::channel::mpsc

Function channel

source
pub fn channel<T>(buffer: usize) -> (Sender<T>, Receiver<T>)
Expand description

Creates a bounded mpsc channel for communicating between asynchronous tasks.

Being bounded, this channel provides backpressure to ensure that the sender outpaces the receiver by only a limited amount. The channel’s capacity is equal to buffer + num-senders. In other words, each sender gets a guaranteed slot in the channel capacity, and on top of that there are buffer “first come, first serve” slots available to all senders.

The Receiver returned implements the Stream trait, while Sender implements Sink.