Commit 2263703b by FritzFlorian

Fix: Thread sanitizer race.

See the comment in the source. This race should actually not be important, but we fix it anyways for now to make the CI happy.
parent e1b88ef5
Pipeline #1254 passed with stages
in 3 minutes 43 seconds
......@@ -21,10 +21,15 @@ using offset_t = stamped_integer::member_t;
// Single Item in the deque
class work_stealing_deque_item {
// TODO: In our opinion these atomic's are a pure formality to make the thread sanitizer happy,
// as the race occurs in 'pop_head', where ALL CASES reading a corrupt/old value are cases
// where the next CAS fails anywas, thus making these corrupted values have no influence on
// the overall program execution.
// ==> If we find performance problems in this queue, try removing the atoimcs again.
// Pointer to the actual data
pointer_t data_;
std::atomic<pointer_t> data_;
// Index (relative to stack base) to the next and previous element
offset_t next_item_;
std::atomic<offset_t> next_item_;
offset_t previous_item_;
public:
......@@ -32,7 +37,7 @@ class work_stealing_deque_item {
template<typename Item>
Item *data() {
return reinterpret_cast<Item *>(data_);
return reinterpret_cast<Item *>(data_.load());
}
template<typename Item>
......@@ -40,7 +45,7 @@ class work_stealing_deque_item {
data_ = reinterpret_cast<pointer_t >(data);
}
offset_t next_item() const { return next_item_; }
offset_t next_item() const { return next_item_.load(); }
void set_next_item(offset_t next_item) { next_item_ = next_item; }
offset_t previous_item() const { return previous_item_; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment