Align the first element of the Waiter struct instead of padding it. This reduces its memory footprint a bit while achieving the goal of preventing false sharing

This commit is contained in:
Benoit Steiner 2016-06-02 21:17:41 -07:00
parent 5b77481d58
commit c3c8ad8046

View File

@ -169,7 +169,8 @@ class EventCount {
class Waiter { class Waiter {
friend class EventCount; friend class EventCount;
std::atomic<Waiter*> next; // Align to 128 byte boundary to prevent false sharing with other Waiter objects in the same vector.
EIGEN_ALIGN_TO_BOUNDARY(128) std::atomic<Waiter*> next;
std::mutex mu; std::mutex mu;
std::condition_variable cv; std::condition_variable cv;
uint64_t epoch; uint64_t epoch;
@ -179,8 +180,6 @@ class EventCount {
kWaiting, kWaiting,
kSignaled, kSignaled,
}; };
// Prevent false sharing with other Waiter objects in the same vector.
char pad_[128];
}; };
private: private: