mirror of
https://github.com/cameron314/concurrentqueue.git
synced 2026-01-18 06:11:16 +01:00
Fixed bug in example (count can become negative) -- see issue #252
This commit is contained in:
@@ -186,7 +186,7 @@ for (int i = 0; i != ProducerCount; ++i) {
|
||||
for (int i = 0; i != ConsumerCount; ++i) {
|
||||
consumers[i] = std::thread([&]() {
|
||||
Item item;
|
||||
while (promisedElementsRemaining.fetch_sub(1, std::memory_order_relaxed)) {
|
||||
while (promisedElementsRemaining.fetch_sub(1, std::memory_order_relaxed) > 0) {
|
||||
q.wait_dequeue(item);
|
||||
consumeItem(item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user