docs: List<LogSegment> markDeletedWhile(LogSegmentFilter filter) throws IOException {
          synchronized (lock) {
              List<LogSegment> view = segments.getView();
              List<LogSegment> deletable = new ArrayList<LogSegment>();
              for (LogSegment seg : view) {
                  if (filter.filter(seg)) {
                      deletable.add(seg);
                  }
              }
              for (LogSegment seg : deletable) {
                  seg.setDeleted(true);
              }
              int numToDelete = deletable.size();
              //
              // if we are deleting everything, create a new empty segment
              if (numToDelete == view.size()) {
                  if (view.get(numToDelete - 1).size() > 0) {
                      roll();
                  } else {
                      // If the last segment to be deleted is empty and we roll the log, the new segment will have the same
                      // file name. So simply reuse the last segment and reset the modified time.
                      view.get(numToDelete - 1).getFile().setLastModified(System.currentTimeMillis());
                      numToDelete -= 1;
                  }
              }
              return segments.trunc(numToDelete);
          }
      }