Package io.netty.util.concurrent
Class DefaultMockTicker
- java.lang.Object
-
- io.netty.util.concurrent.DefaultMockTicker
-
- All Implemented Interfaces:
MockTicker,Ticker
final class DefaultMockTicker extends java.lang.Object implements MockTicker
The defaultMockTickerimplementation.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.locks.ReentrantLocklockprivate java.util.concurrent.atomic.AtomicLongnanoTimeprivate java.util.concurrent.locks.ConditionsleeperConditionprivate java.util.Set<java.lang.Thread>sleepersprivate java.util.concurrent.locks.ConditiontickCondition
-
Constructor Summary
Constructors Constructor Description DefaultMockTicker()
-
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.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, wait
-
Methods inherited from interface io.netty.util.concurrent.MockTicker
advanceMillis, initialNanoTime
-
Methods inherited from interface io.netty.util.concurrent.Ticker
sleepMillis
-
-
-
-
Field Detail
-
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
-
-
Method Detail
-
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.
-
awaitSleepingThread
public void awaitSleepingThread(java.lang.Thread thread) throws java.lang.InterruptedExceptionWait 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.
-
-