private synchronized boolean shouldFlush() { if (lastFlush + flushPeriodMillisecond < clock.currentTimeMillis()) { lastFlush = clock.currentTimeMillis(); return true; } return false; }
public TimeBasedFlush(@Nonnull Clock clock, long flushPeriod, @Nonnull TimeUnit unit) { this.clock = clock; this.lastFlush = clock.currentTimeMillis(); this.flushPeriodMillisecond = MILLISECONDS.convert(flushPeriod, unit); }