private void evictBasedOnTimestamp() {
    Instant currentTimestamp = Instant.now();
    TimestampedValue<T> valueInfo = this.elements.peek();

    // continue remove-head if currenttimestamp - head-element's timestamp > durationThreshold
    while (valueInfo != null
        && currentTimestamp.toEpochMilli() - valueInfo.getTimestamp() > this.maxStaleness.toMillis()) {
      this.elements.poll();
      valueInfo = this.elements.peek();
    }
  }
Removes entries from elements to ensure no element has a timestamp more than maxStaleness before current timestamp.
samza-core/src/main/scala/org/apache/samza/diagnostics/BoundedList.java