Class DefaultMockTicker
java.lang.Object
io.netty.util.concurrent.DefaultMockTicker
- All Implemented Interfaces:
MockTicker, Ticker
The default
MockTicker implementation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ReentrantLockprivate final AtomicLongprivate final Conditionprivate final Condition -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdvances the currentTicker.nanoTime()by the given amount of time.voidawaitSleepingThread(Thread thread) Wait for the given thread to enter thesleep(long, TimeUnit)method, and block.longnanoTime()The time elapsed since initialization of this class in nanoseconds.voidWaits until the given amount of time goes by.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MockTicker
advanceMillis, initialNanoTimeMethods inherited from interface Ticker
sleepMillis
-
Field Details
-
lock
-
tickCondition
-
sleeperCondition
-
nanoTime
-
sleepers
-
-
Constructor Details
-
DefaultMockTicker
DefaultMockTicker()
-
-
Method Details
-
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
Description copied from interface:TickerWaits until the given amount of time goes by.- Specified by:
sleepin interfaceTicker- Parameters:
delay- the amount of delay.unit- theTimeUnitofdelay.- Throws:
InterruptedException- See Also:
-
awaitSleepingThread
Wait for the given thread to enter thesleep(long, TimeUnit)method, and block.- Throws:
InterruptedException
-
advance
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.
-