public void waitUntilInsideWindow(long to) {
    try {
      monitor.enterWhen(monitor.newGuard(() -> to - tail.longValue() < windowSize));
      monitor.leave();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new RuntimeException(e);
    }
  }
Blocks until another thread moves the tail to at least {@code to - windowSize}.
planetiler-core/src/main/java/com/onthegomap/planetiler/util/SlidingWindow.java