public void pollForChanges(Duration delay, FunctionThatThrows<Set<Path>, Set<Path>> action) {
    while (!Thread.currentThread().isInterrupted()) {
      var changes = poll();
      if (!changes.isEmpty()) {
        setWatched(action.runAndWrapException(changes));
      }
      try {
        Thread.sleep(delay.toMillis());
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }
  }
Blocks and invokes {@code action} every time one of the watched files changes, checking every {@code delay}
interval.
planetiler-core/src/main/java/com/onthegomap/planetiler/util/FileWatcher.java