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 originTimeout = timeout;
long startSeq;
try {
do {
do {
do {
startSeq = synchronizer.currentSequence();
for (final T bagEntry : sharedList) {
if (bagEntry.state().compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) {
return bagEntry;
}
startSeq = synchronizer.currentSequence();
for (final T bagEntry : sharedList) {
if (bagEntry.state().compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) {
return bagEntry;
}
} while (startSeq < synchronizer.currentSequence());
if (addItemFuture == null || addItemFuture.isDone()) {
addItemFuture = listener.addBagItem();
}
timeout = originTimeout - (System.nanoTime() - startScan);
} while (timeout > 1000L && synchronizer.waitUntilSequenceExceeded(startSeq, timeout));
}
finally {
synchronizer.signal();
}
} while (startSeq < synchronizer.currentSequence());
if (addItemFuture == null || addItemFuture.isDone()) {
addItemFuture = listener.addBagItem();
}
timeout = originTimeout - (System.nanoTime() - startScan);
} while (timeout > 1000L && synchronizer.waitUntilSequenceExceeded(startSeq, timeout));
return null;
}

Loading…
Cancel
Save