@Override public JobHandle schedule( Group group, Runnable job ) { JobHandle handle = schedule( job, now() ); processSchedule(); return handle; }
@Override public JobHandle scheduleRecurring( Group group, Runnable job, long period, TimeUnit timeUnit ) { JobHandle handle = scheduleRecurring( job, now(), timeUnit.toMillis( period ) ); processSchedule(); return handle; }
@Override public void close() { shutdown(); }
private long now() { return instant().toEpochMilli(); }
@Override public FakeClock forward( long delta, TimeUnit unit ) { super.forward( delta, unit ); processSchedule(); return this; }
@Override public JobHandle schedule( Group group, Runnable job, long initialDelay, TimeUnit timeUnit ) { JobHandle handle = schedule( job, now() + timeUnit.toMillis( initialDelay ) ); if ( initialDelay <= 0 ) { processSchedule(); } return handle; }
@Override public JobHandle scheduleRecurring( Group group, Runnable job, long initialDelay, long period, TimeUnit timeUnit ) { JobHandle handle = scheduleRecurring( job, now() + timeUnit.toMillis( initialDelay ), timeUnit.toMillis( period ) ); if ( initialDelay <= 0 ) { processSchedule(); } return handle; }