PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://github.com/jruderman/rust
Rust | 26 lines | 18 code | 6 blank | 2 comment | 1 complexity | 4275042d5bab87ef630d482c6053a39e MD5 | raw file
 1use std;
 2import task;
 3
 4fn main() { test00(); }
 5
 6fn start(&&task_number: int) { debug!{"Started / Finished task."}; }
 7
 8fn test00() {
 9    let i: int = 0;
10    let mut result = none;
11    do task::task().future_result(|-r| { result = some(r); }).spawn {
12        start(i)
13    }
14
15    // Sleep long enough for the task to finish.
16    let mut i = 0;
17    while i < 10000 {
18        task::yield();
19        i += 1;
20    }
21
22    // Try joining tasks that have already finished.
23    future::get(option::unwrap(result));
24
25    debug!{"Joined task."};
26}