rust/src/test/run-fail/task-comm-14.rs

31 lines
564 B
Rust
Raw Normal View History

// xfail-test
2011-07-27 07:48:34 -05:00
io fn main() {
let port<int> po = port();
2011-07-27 07:48:34 -05:00
// Spawn 10 tasks each sending us back one int.
let int i = 10;
while (i > 0) {
log i;
spawn "child" child(i, chan(po));
i = i - 1;
}
// Spawned tasks are likely killed before they get a chance to send
// anything back, so we deadlock here.
i = 10;
let int value = 0;
while (i > 0) {
log i;
po |> value;
i = i - 1;
}
log "main thread exiting";
}
io fn child(int x, chan<int> ch) {
2011-07-27 07:48:34 -05:00
log x;
ch <| x;
}