Function crossbeam_channel::unbounded
[−]
[src]
pub fn unbounded<T>() -> (Sender<T>, Receiver<T>)
Creates a new channel of unbounded capacity, returning the sender/receiver halves.
This type of channel can hold an unbounded number of messages, i.e. it has infinite capacity.
Examples
use crossbeam_channel::unbounded; use std::thread; let (tx, rx) = unbounded(); // An expensive computation. fn fib(n: i32) -> i32 { if n <= 1 { n } else { fib(n - 1) + fib(n - 2) } } // Spawn a thread doing expensive computation. thread::spawn(move || { tx.send(fib(20)).unwrap(); }); // Do some useful work for a while... // Let's see what's the result of the expensive computation. println!("{}", rx.recv().unwrap());