private void prune() {
   // Remove all values that are too old
   TimeInterval periodAllowed = cachedPeriod.before(buffer.getLast().getTimestamp());
   while (!buffer.isEmpty() && !periodAllowed.contains(buffer.getFirst().getTimestamp())) {
     // Discard value
     buffer.removeFirst();
   }
 }
  /**
   * Returns all values since last check and removes values from the queue.
   *
   * @return a new array with the value; never null
   */
  @Override
  public List<T> getValue() {
    synchronized (buffer) {
      if (buffer.isEmpty()) return Collections.emptyList();

      // period allowed time = latest - msCache / 1000
      TimeInterval periodAllowed =
          cachedPeriod.before(TimeStamp.asTimestamp(TimeSupport.timestampOf(buffer.getLast())));
      while (!buffer.isEmpty()
          && !periodAllowed.contains(
              TimeStamp.asTimestamp(TimeSupport.timestampOf(buffer.getFirst())))) {
        // Discard value
        buffer.removeFirst();
      }
      return new ArrayList<T>(buffer);
    }
  }