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

29 lines
511 B
Rust
Raw Normal View History

use std;
import task;
import comm;
fn start(c: comm::chan<comm::chan<~str>>) {
2011-09-16 18:29:40 +00:00
let p = comm::port();
comm::send(c, comm::chan(p));
let mut a;
let mut b;
2011-09-16 18:29:40 +00:00
a = comm::recv(p);
assert a == ~"A";
log(error, a);
2011-09-16 18:29:40 +00:00
b = comm::recv(p);
assert b == ~"B";
log(error, b);
2010-08-11 22:05:33 +00:00
}
2011-04-19 20:35:49 +00:00
fn main() {
2011-09-16 18:29:40 +00:00
let p = comm::port();
2012-01-05 05:14:53 +00:00
let ch = comm::chan(p);
2012-06-30 23:19:07 +00:00
let child = task::spawn(|| start(ch) );
2011-09-16 18:29:40 +00:00
let c = comm::recv(p);
comm::send(c, ~"A");
comm::send(c, ~"B");
task::yield();
}