We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a455088 + 88336da commit 8972d5aCopy full SHA for 8972d5a
wsq.hpp
@@ -4,6 +4,7 @@
4
#include <vector>
5
#include <optional>
6
#include <cassert>
7
+#include <new>
8
9
/**
10
@class: WorkStealingQueue
@@ -61,8 +62,14 @@ class WorkStealingQueue {
61
62
63
};
64
- std::atomic<int64_t> _top;
65
- std::atomic<int64_t> _bottom;
+ // avoids false sharing between _top and _bottom
66
+#ifdef __cpp_lib_hardware_interference_size
67
+ alignas(std::hardware_destructive_interference_size) std::atomic<int64_t> _top;
68
+ alignas(std::hardware_destructive_interference_size) std::atomic<int64_t> _bottom;
69
+#else
70
+ alignas(64) std::atomic<int64_t> _top;
71
+ alignas(64) std::atomic<int64_t> _bottom;
72
+#endif
73
std::atomic<Array*> _array;
74
std::vector<Array*> _garbage;
75
0 commit comments