diff --git a/lockfree/spsc/bipartite_buf_impl.hpp b/lockfree/spsc/bipartite_buf_impl.hpp index d67c36a..516beea 100644 --- a/lockfree/spsc/bipartite_buf_impl.hpp +++ b/lockfree/spsc/bipartite_buf_impl.hpp @@ -77,15 +77,16 @@ T *BipartiteBuf::WriteAcquire(const size_t free_required) { template void BipartiteBuf::WriteRelease(const size_t written) { - /* Preload variables with adequate memory ordering */ size_t w = _w.load(std::memory_order_relaxed); - size_t i = _i.load(std::memory_order_relaxed); /* If the write wrapped set the invalidate index and reset write index*/ + size_t i; if (_write_wrapped) { _write_wrapped = false; i = w; w = 0U; + } else { + i = _i.load(std::memory_order_relaxed); } /* Increment the write index */