rust/src/test/run-pass/task-comm-10.rs

28 lines
499 B
Rust
Raw Normal View History

use std;
import task;
import comm;
2011-10-20 22:34:04 -05:00
fn start(c: comm::chan<comm::chan<str>>) {
2011-09-16 13:29:40 -05:00
let p = comm::port();
comm::send(c, comm::chan(p));
let a;
let b;
2011-09-16 13:29:40 -05:00
a = comm::recv(p);
assert a == "A";
log_full(core::error, a);
2011-09-16 13:29:40 -05:00
b = comm::recv(p);
assert b == "B";
log_full(core::error, b);
2010-08-11 17:05:33 -05:00
}
2011-04-19 15:35:49 -05:00
fn main() {
2011-09-16 13:29:40 -05:00
let p = comm::port();
let child = task::spawn(comm::chan(p), start);
2011-09-16 13:29:40 -05:00
let c = comm::recv(p);
comm::send(c, "A");
comm::send(c, "B");
task::yield();
}