2011-07-29 22:09:25 -07:00
|
|
|
use std;
|
2011-08-15 16:38:23 -07:00
|
|
|
import std::vec;
|
2011-07-29 22:09:25 -07:00
|
|
|
import std::task;
|
|
|
|
import std::uint;
|
2011-09-01 17:27:58 -07:00
|
|
|
import std::str;
|
2011-07-29 22:09:25 -07:00
|
|
|
|
2011-10-13 15:37:07 -07:00
|
|
|
fn# f(&&n: uint) {
|
2011-07-29 22:09:25 -07:00
|
|
|
let i = 0u;
|
2011-08-20 13:02:26 -07:00
|
|
|
while i < n {
|
2011-10-13 21:23:07 -07:00
|
|
|
task::join(task::spawn_joinable((), g));
|
2011-09-02 15:34:58 -07:00
|
|
|
i += 1u;
|
|
|
|
}
|
2011-07-29 22:09:25 -07:00
|
|
|
}
|
|
|
|
|
2011-10-13 15:37:07 -07:00
|
|
|
fn# g(&&_i: ()) { }
|
2011-07-29 22:09:25 -07:00
|
|
|
|
2011-09-02 15:34:58 -07:00
|
|
|
fn main(args: [str]) {
|
2011-08-19 15:16:48 -07:00
|
|
|
let n =
|
|
|
|
if vec::len(args) < 2u {
|
|
|
|
10u
|
2011-09-01 17:27:58 -07:00
|
|
|
} else { uint::parse_buf(str::bytes(args[1]), 10u) };
|
2011-07-29 22:09:25 -07:00
|
|
|
let i = 0u;
|
2011-10-13 21:23:07 -07:00
|
|
|
while i < n { task::spawn(copy n, f); i += 1u; }
|
2011-08-15 11:34:12 -07:00
|
|
|
}
|