2010-08-24 23:06:56 -05:00
|
|
|
use std;
|
2011-07-12 17:27:17 -05:00
|
|
|
import std::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
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn start(task_number: int) { log "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;
|
2011-08-13 17:20:11 -05:00
|
|
|
let t = task::_spawn(bind 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.
|
2011-07-12 17:27:17 -05:00
|
|
|
task::sleep(10000u);
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2010-08-24 23:06:56 -05:00
|
|
|
// Try joining tasks that have already finished.
|
2011-08-13 17:20:11 -05:00
|
|
|
task::join_id(t);
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2011-05-12 10:24:54 -05:00
|
|
|
log "Joined task.";
|
2011-08-06 12:07:39 -05:00
|
|
|
}
|