Remove code meant to handle what is not believed to be a non-existent race condition.

pull/333/head
Brett Wooldridge 10 years ago
parent f5c248c4f4
commit 1e4f078d5d

@ -124,27 +124,22 @@ public class ConcurrentBag<T extends IConcurrentBagEntry> implements AutoCloseab
final long startScan = System.nanoTime(); final long startScan = System.nanoTime();
final long originTimeout = timeout; final long originTimeout = timeout;
long startSeq; long startSeq;
try { do {
do { do {
do { startSeq = synchronizer.currentSequence();
startSeq = synchronizer.currentSequence(); for (final T bagEntry : sharedList) {
for (final T bagEntry : sharedList) { if (bagEntry.state().compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) {
if (bagEntry.state().compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) { return bagEntry;
return bagEntry;
}
} }
} while (startSeq < synchronizer.currentSequence());
if (addItemFuture == null || addItemFuture.isDone()) {
addItemFuture = listener.addBagItem();
} }
} while (startSeq < synchronizer.currentSequence());
timeout = originTimeout - (System.nanoTime() - startScan);
} while (timeout > 1000L && synchronizer.waitUntilSequenceExceeded(startSeq, timeout)); if (addItemFuture == null || addItemFuture.isDone()) {
} addItemFuture = listener.addBagItem();
finally { }
synchronizer.signal();
} timeout = originTimeout - (System.nanoTime() - startScan);
} while (timeout > 1000L && synchronizer.waitUntilSequenceExceeded(startSeq, timeout));
return null; return null;
} }

Loading…
Cancel
Save