diff --git a/wsq.hpp b/wsq.hpp index 4cda96d..c73b9ff 100644 --- a/wsq.hpp +++ b/wsq.hpp @@ -4,6 +4,7 @@ #include #include #include +#include /** @class: WorkStealingQueue @@ -61,8 +62,14 @@ class WorkStealingQueue { }; - std::atomic _top; - std::atomic _bottom; + // avoids false sharing between _top and _bottom +#ifdef __cpp_lib_hardware_interference_size + alignas(std::hardware_destructive_interference_size) std::atomic _top; + alignas(std::hardware_destructive_interference_size) std::atomic _bottom; +#else + alignas(64) std::atomic _top; + alignas(64) std::atomic _bottom; +#endif std::atomic _array; std::vector _garbage;