Commit 0d0826da authored by Xavier Thompson's avatar Xavier Thompson

Fix deque.hpp atomics bug introduced in refactor

parent 549d499e
...@@ -64,23 +64,24 @@ namespace typon::fdt::lock_free ...@@ -64,23 +64,24 @@ namespace typon::fdt::lock_free
_bottom.store(bottom, relaxed); _bottom.store(bottom, relaxed);
std::atomic_thread_fence(seq_cst); std::atomic_thread_fence(seq_cst);
u64 top = _top.load(relaxed); u64 top = _top.load(relaxed);
if (top > bottom) pop_type x { Empty };
if (top <= bottom)
{ {
_bottom.store(top, relaxed); x = array->get(bottom);
return { Empty }; if (top == bottom)
} {
T x = array->get(bottom); if (!_top.compare_exchange_strong(top, top + 1, seq_cst, relaxed))
if (top < bottom) {
{ x = { Empty };
return { x }; }
_bottom.store(bottom + 1, relaxed);
}
} }
bool win = _top.compare_exchange_strong(top, top + 1, seq_cst, relaxed); else
_bottom.store(top + 1, relaxed);
if (win)
{ {
return { x }; _bottom.store(bottom + 1, relaxed);
} }
return { Empty }; return x;
} }
pop_type steal() noexcept pop_type steal() noexcept
......
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 to comment