2011-09-01 16:17:11 -05:00
|
|
|
// Vectors are allocated in the Rust kernel's memory region, use of
|
|
|
|
// which requires some amount of synchronization. This test exercises
|
|
|
|
// that synchronization by spawning a number of tasks and then
|
|
|
|
// allocating and freeing vectors.
|
|
|
|
|
|
|
|
use std;
|
|
|
|
import std::vec;
|
|
|
|
import std::uint;
|
2011-09-01 19:27:58 -05:00
|
|
|
import std::str;
|
2011-09-01 16:17:11 -05:00
|
|
|
import std::task;
|
|
|
|
|
2011-10-13 17:37:07 -05:00
|
|
|
fn# f(&&n: uint) {
|
2011-09-01 16:17:11 -05:00
|
|
|
for each i in uint::range(0u, n) {
|
|
|
|
let v: [u8] = [];
|
|
|
|
vec::reserve(v, 1000u);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-02 17:34:58 -05:00
|
|
|
fn main(args: [str]) {
|
|
|
|
let n =
|
|
|
|
if vec::len(args) < 2u {
|
|
|
|
100u
|
|
|
|
} else { uint::parse_buf(str::bytes(args[1]), 10u) };
|
2011-10-13 17:37:07 -05:00
|
|
|
for each i in uint::range(0u, 100u) { task::spawn2(copy n, f); }
|
2011-09-02 17:34:58 -05:00
|
|
|
}
|