2011-03-25 14:19:20 -05:00
|
|
|
// xfail-stage0
|
2011-05-03 20:13:51 -05:00
|
|
|
// xfail-stage1
|
|
|
|
// xfail-stage2
|
2010-07-28 18:58:17 -05:00
|
|
|
fn main() -> () {
|
2010-08-09 08:53:37 -05:00
|
|
|
log "===== SPAWNING and JOINING TASKS =====";
|
|
|
|
test00(false);
|
|
|
|
log "===== SPAWNING and JOINING THREAD TASKS =====";
|
2010-07-28 18:58:17 -05:00
|
|
|
test00(true);
|
2010-07-19 16:05:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn start(int task_number) {
|
|
|
|
log "Started task.";
|
|
|
|
let int i = 0;
|
|
|
|
while (i < 10000) {
|
|
|
|
i = i + 1;
|
|
|
|
}
|
|
|
|
log "Finished task.";
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test00(bool create_threads) {
|
2010-08-09 08:53:37 -05:00
|
|
|
let int number_of_tasks = 8;
|
2010-07-19 16:05:18 -05:00
|
|
|
|
|
|
|
let int i = 0;
|
2011-05-16 20:21:22 -05:00
|
|
|
let vec[task] tasks = [];
|
2010-07-19 16:05:18 -05:00
|
|
|
while (i < number_of_tasks) {
|
|
|
|
i = i + 1;
|
|
|
|
if (create_threads) {
|
2011-05-16 20:21:22 -05:00
|
|
|
tasks += [spawn thread start(i)];
|
2010-07-19 16:05:18 -05:00
|
|
|
} else {
|
2011-05-16 20:21:22 -05:00
|
|
|
tasks += [spawn start(i)];
|
2010-07-19 16:05:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (task t in tasks) {
|
|
|
|
join t;
|
|
|
|
}
|
2010-07-28 18:58:17 -05:00
|
|
|
|
|
|
|
log "Joined all task.";
|
2010-07-19 16:05:18 -05:00
|
|
|
}
|