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 java.util.concurrent.locks.ReentrantLockprivate final java.util.concurrent.atomic.AtomicLongprivate final java.util.concurrent.locks.Conditionprivate final java.util.Set<java.lang.Thread> private final java.util.concurrent.locks.Condition -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadvance(long amount, java.util.concurrent.TimeUnit unit) Advances the currentTicker.nanoTime()by the given amount of time.voidawaitSleepingThread(java.lang.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.voidsleep(long delay, java.util.concurrent.TimeUnit unit) Waits until the given amount of time goes by.Methods inherited from class java.lang.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
private final java.util.concurrent.locks.ReentrantLock lock -
tickCondition
private final java.util.concurrent.locks.Condition tickCondition -
sleeperCondition
private final java.util.concurrent.locks.Condition sleeperCondition -
nanoTime
private final java.util.concurrent.atomic.AtomicLong nanoTime -
sleepers
private final java.util.Set<java.lang.Thread> sleepers
-
-
Constructor Details
-
DefaultMockTicker
DefaultMockTicker()
-
-
Method Details
-
nanoTime
-
sleep
public void sleep(long delay, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException Description copied from interface:TickerWaits until the given amount of time goes by. -
awaitSleepingThread
public void awaitSleepingThread(java.lang.Thread thread) throws java.lang.InterruptedException Wait for the given thread to enter thesleep(long, TimeUnit)method, and block.- Throws:
java.lang.InterruptedException
-
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.
-