[][src]Function flume::bounded

pub fn bounded<T>(n: usize) -> (Sender<T>, Receiver<T>)

Create a new channel with an upper bound.

Create an bounded channel with a Sender and Receiver connected to each end respectively. Values sent in one end of the channel will be received on the other end. The channel is thread-safe, and both sender and receiver may be sent to threads as necessary. In addition, Sender may be cloned. If there is no space left for new messages, calls to Sender::send will block (unblocking once a receiver has made space).

Examples

let (tx, rx) = flume::bounded(32);

tx.send(42).unwrap();
assert_eq!(rx.recv().unwrap(), 42);