unbounded

Function unbounded 

Source
pub fn unbounded<T>() -> (Sender<T>, Receiver<T>)
Expand description

Creates an unbounded channel, which has unlimited capacity.

This function creates a pair of sender and receiver halves of a channel. Values sent on the sender half will be received on the receiver half, in the same order in which they were sent. The channel is thread-safe, and both sender and receiver halves can be sent to or shared between threads as needed. Additionally, both sender and receiver halves can be cloned.

Producers can send and consumers can receive messages asynchronously or synchronously.

ยงExamples

let (tx, rx) = loole::unbounded();

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