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

29 lines
500 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(error, a);
2011-09-16 13:29:40 -05:00
b = comm::recv(p);
assert b == "B";
log(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();
2012-01-04 23:14:53 -06:00
let ch = comm::chan(p);
let child = task::spawn {|| start(ch); };
2011-09-16 13:29:40 -05:00
let c = comm::recv(p);
comm::send(c, "A");
comm::send(c, "B");
task::yield();
}