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

28 lines
481 B
Rust
Raw Normal View History

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