Skip to content

Commit a724a69

Browse files
committed
Fixed bug in example (count can become negative) -- see issue cameron314#252
1 parent 8e960d6 commit a724a69

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

samples.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ for (int i = 0; i != ProducerCount; ++i) {
186186
for (int i = 0; i != ConsumerCount; ++i) {
187187
consumers[i] = std::thread([&]() {
188188
Item item;
189-
while (promisedElementsRemaining.fetch_sub(1, std::memory_order_relaxed)) {
189+
while (promisedElementsRemaining.fetch_sub(1, std::memory_order_relaxed) > 0) {
190190
q.wait_dequeue(item);
191191
consumeItem(item);
192192
}

0 commit comments

Comments
 (0)