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