@Test public void reschedulesShortDelay() { assertFalse(runner.ran); rescheduler.reschedule(50, TimeUnit.NANOSECONDS); assertFalse(runner.ran); assertFalse(exec.executed); rescheduler.reschedule(1, TimeUnit.NANOSECONDS); assertFalse(runner.ran); assertFalse(exec.executed); scheduler.forwardNanos(1); assertTrue(runner.ran); assertTrue(exec.executed); }
void reschedule(long delay, TimeUnit timeUnit) { long delayNanos = timeUnit.toNanos(delay); long newRunAtNanos = nanoTime() + delayNanos; enabled = true; if (newRunAtNanos - runAtNanos < 0 || wakeUp == null) { if (wakeUp != null) { wakeUp.cancel(false); } wakeUp = scheduler.schedule(new FutureRunnable(), delayNanos, TimeUnit.NANOSECONDS); } runAtNanos = newRunAtNanos; }
Rescheduler { void reschedule(long delay, TimeUnit timeUnit) { long delayNanos = timeUnit.toNanos(delay); long newRunAtNanos = nanoTime() + delayNanos; enabled = true; if (newRunAtNanos - runAtNanos < 0 || wakeUp == null) { if (wakeUp != null) { wakeUp.cancel(false); } wakeUp = scheduler.schedule(new FutureRunnable(), delayNanos, TimeUnit.NANOSECONDS); } runAtNanos = newRunAtNanos; } }
Rescheduler { void reschedule(long delay, TimeUnit timeUnit) { long delayNanos = timeUnit.toNanos(delay); long newRunAtNanos = nanoTime() + delayNanos; enabled = true; if (newRunAtNanos - runAtNanos < 0 || wakeUp == null) { if (wakeUp != null) { wakeUp.cancel(false); } wakeUp = scheduler.schedule(new FutureRunnable(), delayNanos, TimeUnit.NANOSECONDS); } runAtNanos = newRunAtNanos; } Rescheduler(
      Runnable r,
      Executor serializingExecutor,
      ScheduledExecutorService scheduler,
      Stopwatch stopwatch); }
Rescheduler { void reschedule(long delay, TimeUnit timeUnit) { long delayNanos = timeUnit.toNanos(delay); long newRunAtNanos = nanoTime() + delayNanos; enabled = true; if (newRunAtNanos - runAtNanos < 0 || wakeUp == null) { if (wakeUp != null) { wakeUp.cancel(false); } wakeUp = scheduler.schedule(new FutureRunnable(), delayNanos, TimeUnit.NANOSECONDS); } runAtNanos = newRunAtNanos; } Rescheduler(
      Runnable r,
      Executor serializingExecutor,
      ScheduledExecutorService scheduler,
      Stopwatch stopwatch);  }
Rescheduler { void reschedule(long delay, TimeUnit timeUnit) { long delayNanos = timeUnit.toNanos(delay); long newRunAtNanos = nanoTime() + delayNanos; enabled = true; if (newRunAtNanos - runAtNanos < 0 || wakeUp == null) { if (wakeUp != null) { wakeUp.cancel(false); } wakeUp = scheduler.schedule(new FutureRunnable(), delayNanos, TimeUnit.NANOSECONDS); } runAtNanos = newRunAtNanos; } Rescheduler(
      Runnable r,
      Executor serializingExecutor,
      ScheduledExecutorService scheduler,
      Stopwatch stopwatch);   }