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:
parent
65abe2c6dc
commit
ea889742d7
1 changed files with 4 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue