Skip to content

Commit 0d54c67

Browse files
committed
Fix chain of happens-before between dequeue operations in a block and that block's reuse when empty, affecting implicit producers (see #404)
1 parent e74b07d commit 0d54c67

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

concurrentqueue.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ class ConcurrentQueue
16041604
}
16051605
else {
16061606
// Increment counter
1607-
auto prevVal = elementsCompletelyDequeued.fetch_add(1, std::memory_order_release);
1607+
auto prevVal = elementsCompletelyDequeued.fetch_add(1, std::memory_order_acq_rel);
16081608
assert(prevVal < BLOCK_SIZE);
16091609
return prevVal == BLOCK_SIZE - 1;
16101610
}
@@ -1627,7 +1627,7 @@ class ConcurrentQueue
16271627
}
16281628
else {
16291629
// Increment counter
1630-
auto prevVal = elementsCompletelyDequeued.fetch_add(count, std::memory_order_release);
1630+
auto prevVal = elementsCompletelyDequeued.fetch_add(count, std::memory_order_acq_rel);
16311631
assert(prevVal + count <= BLOCK_SIZE);
16321632
return prevVal + count == BLOCK_SIZE;
16331633
}

0 commit comments

Comments
 (0)