Created
November 2, 2012 05:36
-
-
Save brson/3998915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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