Skip to content

Commit

Permalink
Using unsafe pointers to share closures.
Browse files Browse the repository at this point in the history
This prevents the tons of copying problems we were having before, which means we only have a 5x slowdown now.
  • Loading branch information
eholk committed May 22, 2012
1 parent 65abe2c commit ea88974
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/test/bench/graph500-bfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ea88974

Please sign in to comment.