rust/src/test/run-pass/task-comm-12.rs

26 lines
529 B
Rust
Raw Normal View History

extern mod std;
2011-07-27 07:19:39 -05:00
fn main() { test00(); }
2012-08-22 19:24:52 -05:00
fn start(&&task_number: int) { debug!("Started / Finished task."); }
fn test00() {
2011-07-27 07:19:39 -05:00
let i: int = 0;
2012-08-20 14:23:37 -05:00
let mut result = None;
do task::task().future_result(|+r| { result = Some(r); }).spawn {
start(i)
}
// Sleep long enough for the task to finish.
let mut i = 0;
while i < 10000 {
task::yield();
i += 1;
}
// Try joining tasks that have already finished.
2012-08-13 23:36:52 -05:00
future::get(&option::unwrap(result));
2012-08-22 19:24:52 -05:00
debug!("Joined task.");
}