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

26 lines
532 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;
2012-09-19 00:45:24 -05:00
do task::task().future_result(|+r| { result = Some(move 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.
option::unwrap(move result).recv();
2012-08-22 19:24:52 -05:00
debug!("Joined task.");
}