2011-07-27 07:48:34 -05:00
|
|
|
// -*- rust -*-
|
|
|
|
|
2011-08-11 00:06:46 -05:00
|
|
|
fn sub(parent: chan[int], id: int) {
|
2011-07-27 07:48:34 -05:00
|
|
|
if (id == 0) {
|
|
|
|
parent <| 0;
|
|
|
|
} else {
|
2011-08-11 00:06:46 -05:00
|
|
|
let p: port[int] = port();
|
|
|
|
let child = spawn sub(chan(p), id-1);
|
|
|
|
let y: int; p |> y;
|
2011-07-27 07:48:34 -05:00
|
|
|
parent <| y + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2011-08-11 00:06:46 -05:00
|
|
|
let p: port[int] = port();
|
|
|
|
let child = spawn sub(chan(p), 200);
|
|
|
|
let y: int; p |> y;
|
2011-07-27 07:48:34 -05:00
|
|
|
log "transmission complete";
|
|
|
|
log y;
|
2011-08-11 00:06:46 -05:00
|
|
|
assert (y == 200);
|
2011-07-27 07:48:34 -05:00
|
|
|
}
|