Package io.netty.util.concurrent
Interface MockTicker
- All Superinterfaces:
Ticker
A fake
Ticker that allows the caller control the flow of time.
This can be useful when you test time-sensitive logic without waiting for too long
or introducing flakiness due to non-deterministic nature of system clock.-
Method Summary
Modifier and TypeMethodDescriptionvoidAdvances the currentTicker.nanoTime()by the given amount of time.default voidadvanceMillis(long amountMillis) Advances the currentTicker.nanoTime()by the given amount of time.default longThe initial value used for delay and computations based upon a monotonic time source.Methods inherited from interface io.netty.util.concurrent.Ticker
nanoTime, sleep, sleepMillis
-
Method Details
-
initialNanoTime
default long initialNanoTime()Description copied from interface:TickerThe initial value used for delay and computations based upon a monotonic time source.- Specified by:
initialNanoTimein interfaceTicker- Returns:
- initial value used for delay and computations based upon a monotonic time source.
-
advance
Advances the currentTicker.nanoTime()by the given amount of time.- Parameters:
amount- the amount of time to advance this ticker by.unit- theTimeUnitofamount.
-
advanceMillis
default void advanceMillis(long amountMillis) Advances the currentTicker.nanoTime()by the given amount of time.- Parameters:
amountMillis- the number of milliseconds to advance this ticker by.
-