2010-08-24 21:06:56 -07:00
|
|
|
use std;
|
2011-07-12 15:27:17 -07:00
|
|
|
import std::task;
|
2010-08-24 21:06:56 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn main() { test00(); }
|
2010-08-24 21:06:56 -07:00
|
|
|
|
2011-10-20 20:34:04 -07:00
|
|
|
fn start(&&task_number: int) { log "Started / Finished task."; }
|
2011-07-13 15:44:09 -07:00
|
|
|
|
|
|
|
fn test00() {
|
2011-07-27 14:19:39 +02:00
|
|
|
let i: int = 0;
|
2011-10-13 21:23:07 -07:00
|
|
|
let t = task::spawn_joinable(i, start);
|
2011-07-13 15:44:09 -07:00
|
|
|
|
2010-08-24 21:06:56 -07:00
|
|
|
// Sleep long enough for the task to finish.
|
2011-07-12 15:27:17 -07:00
|
|
|
task::sleep(10000u);
|
2011-07-13 15:44:09 -07:00
|
|
|
|
2010-08-24 21:06:56 -07:00
|
|
|
// Try joining tasks that have already finished.
|
2011-08-25 11:20:43 -07:00
|
|
|
task::join(t);
|
2011-07-13 15:44:09 -07:00
|
|
|
|
2011-05-12 17:24:54 +02:00
|
|
|
log "Joined task.";
|
2011-08-06 10:07:39 -07:00
|
|
|
}
|