Skip to content

Instantly share code, notes, and snippets.

@brson
Created November 2, 2012 05:36
Show Gist options
  • Save brson/3998915 to your computer and use it in GitHub Desktop.
Save brson/3998915 to your computer and use it in GitHub Desktop.
extern mod std;
use core::pipes::*;
use std::comm::DuplexStream;
use core::task;
fn main () {
let (left_chan, right_port): (Chan<~str>, Port<~str>) = stream();
let (right_chan, left_port): (Chan<int>, Port<int>) = stream();
do task::spawn() |move left_chan, move left_port| {
left_chan.send(~"abc");
assert left_port.recv() == 123;
assert !left_port.peek();
}
do task::spawn() |move right_chan, move right_port| {
assert right_port.recv() == ~"abc";
right_chan.send(123);
assert !right_port.peek();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment