2010-08-24 23:06:56 -05:00
|
|
|
use std;
|
2011-12-13 18:25:51 -06:00
|
|
|
import task;
|
2010-08-24 23:06:56 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn main() { test00(); }
|
2010-08-24 23:06:56 -05:00
|
|
|
|
2012-07-30 18:01:07 -05:00
|
|
|
fn start(&&task_number: int) { debug!{"Started / Finished task."}; }
|
2011-07-13 17:44:09 -05:00
|
|
|
|
|
|
|
fn test00() {
|
2011-07-27 07:19:39 -05:00
|
|
|
let i: int = 0;
|
2012-07-23 18:58:47 -05:00
|
|
|
let mut result = none;
|
2012-08-07 13:26:03 -05:00
|
|
|
do task::task().future_result(|+r| { result = some(r); }).spawn {
|
2012-07-23 18:58:47 -05:00
|
|
|
start(i)
|
|
|
|
}
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2010-08-24 23:06:56 -05:00
|
|
|
// Sleep long enough for the task to finish.
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut i = 0;
|
2012-02-02 17:48:08 -06:00
|
|
|
while i < 10000 {
|
|
|
|
task::yield();
|
|
|
|
i += 1;
|
|
|
|
}
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2010-08-24 23:06:56 -05:00
|
|
|
// Try joining tasks that have already finished.
|
2012-08-13 23:36:52 -05:00
|
|
|
future::get(&option::unwrap(result));
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2012-07-30 18:01:07 -05:00
|
|
|
debug!{"Joined task."};
|
2011-08-06 12:07:39 -05:00
|
|
|
}
|