blob: c0f97c85bce2fa90a952aee7ec41da9b3ed2f08d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
extern mod std;
fn main() { test00(); }
fn start(&&task_number: int) { debug!("Started / Finished task."); }
fn test00() {
let i: int = 0;
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.
future::get(&option::unwrap(result));
debug!("Joined task.");
}
|