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

29 lines
373 B
Rust
Raw Normal View History

use std;
import std::task;
2011-07-27 07:19:39 -05:00
fn start(c: chan[chan[str]]) {
let p: port[str];
let a;
let b;
p = port();
2010-08-11 17:05:33 -05:00
c <| chan(p);
p |> a;
log_err a;
p |> b;
log_err b;
2010-08-11 17:05:33 -05:00
}
2011-04-19 15:35:49 -05:00
fn main() {
2011-07-27 07:19:39 -05:00
let p: port[chan[str]];
let child;
p = port();
child = spawn start(chan(p));
2011-07-27 07:19:39 -05:00
let c;
p |> c;
2010-08-11 17:05:33 -05:00
c <| "A";
c <| "B";
task::yield();
2011-07-27 07:19:39 -05:00
}