Package io.netty.channel.embedded
Class EmbeddedEventLoop.FreezableTicker
- java.lang.Object
-
- io.netty.channel.embedded.EmbeddedEventLoop.FreezableTicker
-
- All Implemented Interfaces:
MockTicker,Ticker
- Enclosing class:
- EmbeddedEventLoop
static final class EmbeddedEventLoop.FreezableTicker extends java.lang.Object implements MockTicker
Ticker that implements the oldEmbeddedChanneltime freezing mechanics.
-
-
Field Summary
Fields Modifier and Type Field Description private longfrozenTimestampWhen time is frozen, the timestamp returned byEmbeddedEventLoop.getCurrentTimeNanos().private longstartTimeWhen time is notfrozen, the base time to subtract fromSystem.nanoTime().private booleantimeFrozenWhether time is currently frozen.private Tickerunfrozen
-
Constructor Summary
Constructors Constructor Description FreezableTicker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvance(long amount, java.util.concurrent.TimeUnit unit)Advances the currentTicker.nanoTime()by the given amount of time.voidfreezeTime()longnanoTime()The time elapsed since initialization of this class in nanoseconds.voidsleep(long delay, java.util.concurrent.TimeUnit unit)Waits until the given amount of time goes by.voidunfreezeTime()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.util.concurrent.MockTicker
advanceMillis, initialNanoTime
-
Methods inherited from interface io.netty.util.concurrent.Ticker
sleepMillis
-
-
-
-
Field Detail
-
unfrozen
private final Ticker unfrozen
-
startTime
private long startTime
When time is notfrozen, the base time to subtract fromSystem.nanoTime(). When time is frozen, this variable is unused.
-
frozenTimestamp
private long frozenTimestamp
When time is frozen, the timestamp returned byEmbeddedEventLoop.getCurrentTimeNanos(). When unfrozen, this is unused.
-
timeFrozen
private boolean timeFrozen
Whether time is currently frozen.
-
-
Method Detail
-
advance
public void advance(long amount, java.util.concurrent.TimeUnit unit)Description copied from interface:MockTickerAdvances the currentTicker.nanoTime()by the given amount of time.- Specified by:
advancein interfaceMockTicker- Parameters:
amount- the amount of time to advance this ticker by.unit- theTimeUnitofamount.
-
nanoTime
public long nanoTime()
Description copied from interface:TickerThe time elapsed since initialization of this class in nanoseconds. This may return a negative number just likeSystem.nanoTime().
-
sleep
public void sleep(long delay, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionDescription copied from interface:TickerWaits until the given amount of time goes by.
-
freezeTime
public void freezeTime()
-
unfreezeTime
public void unfreezeTime()
-
-