From c372fa55560f1cdfdcb566f3027689ba88c46da5 Mon Sep 17 00:00:00 2001 From: Jason Toffaletti Date: Mon, 7 Oct 2013 00:43:34 -0700 Subject: [PATCH] add padding to prevent false sharing --- src/libstd/rt/mpmc_bounded_queue.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libstd/rt/mpmc_bounded_queue.rs b/src/libstd/rt/mpmc_bounded_queue.rs index 8e6ac8f79c7..c0c7d281136 100644 --- a/src/libstd/rt/mpmc_bounded_queue.rs +++ b/src/libstd/rt/mpmc_bounded_queue.rs @@ -40,10 +40,14 @@ struct Node { } struct State { + pad0: [u8, ..64], buffer: ~[Node], mask: uint, + pad1: [u8, ..64], enqueue_pos: AtomicUint, + pad2: [u8, ..64], dequeue_pos: AtomicUint, + pad3: [u8, ..64], } struct Queue { @@ -62,10 +66,14 @@ impl State { Node{sequence:AtomicUint::new(i),value:None} }; State{ + pad0: [0, ..64], buffer: buffer, mask: capacity-1, + pad1: [0, ..64], enqueue_pos: AtomicUint::new(0), + pad2: [0, ..64], dequeue_pos: AtomicUint::new(0), + pad3: [0, ..64], } }