TimeoutScheduler { public void setTimeoutNanos(TimeoutMode mode, long timeoutNanos) { switch (mode) { case SET_FROM_NOW: setTimeoutNanosFromNow(timeoutNanos); break; case SET_FROM_START: setTimeoutNanosFromStart(timeoutNanos); break; case EXTEND: extendTimeoutNanos(timeoutNanos); break; } } TimeoutScheduler(long timeoutNanos); void init(EventExecutor eventLoop, TimeoutTask timeoutTask, long initialTimeoutNanos); void clearTimeout(); void clearTimeout(boolean resetTimeout); void setTimeoutNanos(TimeoutMode mode, long timeoutNanos); void timeoutNow(); boolean isTimedOut(); long timeoutNanos(); CompletableFuture<Void> whenTimingOut(); CompletableFuture<Void> whenTimedOut(); @Nullable Long startTimeNanos();  }
@Test void resetTimeout_zero() { executeInEventLoop(0, timeoutScheduler -> { timeoutScheduler.setTimeoutNanos(SET_FROM_NOW, MILLISECONDS.toNanos(1000)); assertThatThrownBy(() -> { timeoutScheduler.setTimeoutNanos(SET_FROM_NOW, 0); }).isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("timeoutNanos:"); }); }
@Test void resetTimout_multipleNonZero() { executeInEventLoop(0, timeoutScheduler -> { timeoutScheduler.setTimeoutNanos(SET_FROM_NOW, MILLISECONDS.toNanos(1000)); timeoutScheduler.setTimeoutNanos(SET_FROM_NOW, MILLISECONDS.toNanos(500)); }); }