code: private int pruneHeadTasks(Predicate<ReceiveMessageBatchTask> pruneCondition) {
          int numberPruned = 0;
          while (!finishedTasks.isEmpty()) {
              if (pruneCondition.test(finishedTasks.getFirst())) {
                  finishedTasks.removeFirst();
                  numberPruned++;
              } else {
                  break;
              }
          }
          return numberPruned;
      }
docs: Prune all tasks at the beginning of the finishedTasks list that meet the given condition.
  Once a task is found that does not meet the given condition the pruning stops. This method
  assumes that you are holding the finishedTasks lock when invoking it.
  
  @param pruneCondition
  Condition on whether a task is eligible to be pruned
  @return Number of total tasks pruned from finishedTasks