Skip to main content

channel

Function channel 

Source
pub fn channel<T: Send>(capacity: usize) -> (Sender<T>, Receiver<T>)
Expand description

Create a new bounded MPMC channel with the given capacity.

Returns (Sender<T>, Receiver<T>). Both endpoints are cloneable to add more producers or consumers. The capacity is rounded up to at least 1.

§Example (kernel-internal)

let (tx, rx) = channel::<u64>(8);
tx.send(42).unwrap();
assert_eq!(rx.recv().unwrap(), 42);