Skip to content

Commit ea88974

Browse files
committed
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.
1 parent 65abe2c commit ea88974

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/test/bench/graph500-bfs.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,11 @@ fn map_slices<A: send, B: send>(xs: [A], f: fn~(uint, [A]) -> B) -> [B] {
540540
while base < len {
541541
let slice = vec::slice(xs, base,
542542
uint::min(len, base + items_per_task));
543+
let f = ptr::addr_of(f);
543544
futures += [future::spawn() {|copy base|
544-
f(base, slice)
545+
unsafe {
546+
(*f)(base, slice)
547+
}
545548
}];
546549
base += items_per_task;
547550
}

0 commit comments

Comments
 (0)