Function transformable_channels::mpsc::channel [] [src]

pub fn channel<T>() -> (RawSender<T>, Receiver<T>) where T: Send + 'static

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 thread (this channel has an "infinite buffer").

Receivers are identical to those of std::sync::mpsc::Receiver. Senders have the same behavior as those of std::sync::mpsc::Sender, with the exception of error values.

Example

use std::thread;
use transformable_channels::mpsc::*;

let (tx, rx) = channel();

for i in 1 .. 5 {
  tx.send(i).unwrap();
}

thread::spawn(move || {
  for (msg, i) in rx.iter().zip(1..5) {
    assert_eq!(msg, i);
  }
});