rust/src/test/run-pass/task-comm-10.rs
2011-10-20 20:34:04 -07:00

28 lines
479 B
Rust

use std;
import std::task;
import std::comm;
fn start(c: comm::chan<comm::chan<str>>) {
let p = comm::port();
comm::send(c, comm::chan(p));
let a;
let b;
a = comm::recv(p);
assert a == "A";
log_err a;
b = comm::recv(p);
assert b == "B";
log_err b;
}
fn main() {
let p = comm::port();
let child = task::spawn(comm::chan(p), start);
let c = comm::recv(p);
comm::send(c, "A");
comm::send(c, "B");
task::yield();
}