Function sync::comm::channelUnstable
[-]
[+]
[src]
pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>)
Creates a new asynchronous channel, returning the sender/receiver halves.
All data sent on the sender will become available on the receiver, and no send will block the calling task (this channel has an "infinite buffer").
Example
fn main() { // tx is is the sending half (tx for transmission), and rx is the receiving // half (rx for receiving). let (tx, rx) = channel(); // Spawn off an expensive computation spawn(proc() { fn expensive_computation() {} tx.send(expensive_computation()); }); // Do some useful work for awhile // Let's see what that answer was println!("{}", rx.recv()); }// tx is is the sending half (tx for transmission), and rx is the receiving // half (rx for receiving). let (tx, rx) = channel(); // Spawn off an expensive computation spawn(proc() { tx.send(expensive_computation()); }); // Do some useful work for awhile // Let's see what that answer was println!("{}", rx.recv());