rust/src/test/run-pass/many.rs

26 lines
526 B
Rust
Raw Normal View History

2011-07-27 07:48:34 -05:00
// -*- rust -*-
use std;
import std::task;
import std::comm;
fn sub(parent: comm::_chan<int>, id: int) {
if id == 0 {
comm::send(parent, 0);
} else {
let p = comm::mk_port();
let child = task::_spawn(bind sub(p.mk_chan(), id - 1));
let y = p.recv();
comm::send(parent, y + 1);
}
2011-07-27 07:48:34 -05:00
}
fn main() {
let p = comm::mk_port();
let child = task::_spawn(bind sub(p.mk_chan(), 200));
let y = p.recv();
log "transmission complete";
log y;
assert (y == 200);
2011-07-27 07:48:34 -05:00
}