mozilla/rust — pull request #8317 by bblum (2013-08-05 22:48:33+00:00)
Title: Optimize spawn_unlinked.

This lazily initializes the taskgroup structs for ```spawn_unlinked``` tasks. If such a task never spawns another task linked to it (or a descendant of it), its taskgroup is simply never initialized at all.

I benchmarked this with the following test case and observed a 21% speedup (average over 4 runs: 7.85 sec -> 6.20 sec).
```
use std::task;
use std::cell::Cell;
use std::rt::comm;

static NUM: uint = 1024*256;

fn run(f: ~fn()) {
let mut t = task::task();
t.unlinked();
t.spawn(f);
}

fn main() {
do NUM.times {
let (p,c) = comm::oneshot();
let c = Cell::new(c);
do run { c.take().send(()); }
p.recv();
}
}
```