Fixes #1305 ensure that ConcurrentBag.add() does not spin under high load, when waiting threads may never reach 0.

pull/1303/head
Brett Wooldridge 6 years ago
parent 1ac94f16a2
commit 17447199f5

@ -215,7 +215,7 @@ public class ConcurrentBag<T extends IConcurrentBagEntry> implements AutoCloseab
sharedList.add(bagEntry);
// spin until a thread takes it or none are waiting
while (waiters.get() > 0 && bagEntry.getState() != STATE_NOT_IN_USE && !handoffQueue.offer(bagEntry)) {
while (waiters.get() > 0 && bagEntry.getState() == STATE_NOT_IN_USE && !handoffQueue.offer(bagEntry)) {
yield();
}
}

Loading…
Cancel
Save