示例#1
0
 private synchronized boolean shouldFlush() {
   if (lastFlush + flushPeriodMillisecond < clock.currentTimeMillis()) {
     lastFlush = clock.currentTimeMillis();
     return true;
   }
   return false;
 }
示例#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);
 }