Using unsafe pointers to share closures.

This prevents the tons of copying problems we were having before, which means we only have a 5x slowdown now.
This commit is contained in:
Eric Holk 2012-05-17 15:02:31 -07:00
parent 65abe2c6dc
commit ea889742d7

View file

@ -540,8 +540,11 @@ fn map_slices<A: send, B: send>(xs: [A], f: fn~(uint, [A]) -> B) -> [B] {
while base < len {
let slice = vec::slice(xs, base,
uint::min(len, base + items_per_task));
let f = ptr::addr_of(f);
futures += [future::spawn() {|copy base|
f(base, slice)
unsafe {
(*f)(base, slice)
}
}];
base += items_per_task;
}