in src/main/java/com/amazonaws/services/sqs/util/ReceiveQueueBuffer.java [180:207]
protected void satisfyFuturesFromBuffer() {
synchronized (futures) {
synchronized (finishedTasks) {
pruneExpiredFutures();
// attempt to satisfy futures until we run out of either futures or
// finished tasks
Iterator<ReceiveMessageFuture> futureIter = futures.iterator();
while (futureIter.hasNext() && (!finishedTasks.isEmpty())) {
// Remove any expired tasks before attempting to fufill the future
pruneExpiredTasks();
// Fufill the future from a non expired task if there is one. There is still a
// slight chance that the first task could have expired between the time we
// pruned and the time we fufill the future
if (!finishedTasks.isEmpty()) {
if (fulfillFuture(futureIter.next())) {
futureIter.remove();
} else {
// We couldn't produce enough messages, so break the loop and return.
// We may not hit the while loop termination condition because we might
// have inflight FIFO messages that are blocking some of the messages.
return;
}
}
}
}
}
}