Skip to content

Commit c372fa5

Browse files
toffalettibrson
authored andcommitted
add padding to prevent false sharing
1 parent 5876e21 commit c372fa5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libstd/rt/mpmc_bounded_queue.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ struct Node<T> {
4040
}
4141

4242
struct State<T> {
43+
pad0: [u8, ..64],
4344
buffer: ~[Node<T>],
4445
mask: uint,
46+
pad1: [u8, ..64],
4547
enqueue_pos: AtomicUint,
48+
pad2: [u8, ..64],
4649
dequeue_pos: AtomicUint,
50+
pad3: [u8, ..64],
4751
}
4852

4953
struct Queue<T> {
@@ -62,10 +66,14 @@ impl<T: Send> State<T> {
6266
Node{sequence:AtomicUint::new(i),value:None}
6367
};
6468
State{
69+
pad0: [0, ..64],
6570
buffer: buffer,
6671
mask: capacity-1,
72+
pad1: [0, ..64],
6773
enqueue_pos: AtomicUint::new(0),
74+
pad2: [0, ..64],
6875
dequeue_pos: AtomicUint::new(0),
76+
pad3: [0, ..64],
6977
}
7078
}
7179

0 commit comments

Comments
 (0)