Package com.linkedin.alpini.netty4.misc
Class ShutdownableHashedWheelTimer
java.lang.Object
io.netty.util.HashedWheelTimer
com.linkedin.alpini.netty4.misc.ShutdownableHashedWheelTimer
- All Implemented Interfaces:
Shutdownable,io.netty.util.Timer
public class ShutdownableHashedWheelTimer
extends io.netty.util.HashedWheelTimer
implements Shutdownable
-
Field Summary
Fields inherited from class io.netty.util.HashedWheelTimer
WORKER_STATE_INIT, WORKER_STATE_SHUTDOWN, WORKER_STATE_STARTED -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new timer with the default thread factory (Executors.defaultThreadFactory()), default tick duration, and default number of ticks per wheel.ShutdownableHashedWheelTimer(long tickDuration, TimeUnit unit) Creates a new timer with the default thread factory (Executors.defaultThreadFactory()) and default number of ticks per wheel.ShutdownableHashedWheelTimer(long tickDuration, TimeUnit unit, int ticksPerWheel) Creates a new timer with the default thread factory (Executors.defaultThreadFactory()).ShutdownableHashedWheelTimer(ThreadFactory threadFactory) Creates a new timer with the default tick duration and default number of ticks per wheel.ShutdownableHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit) Creates a new timer with the default number of ticks per wheel.ShutdownableHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel) Creates a new timer.ShutdownableHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel, boolean leakDetection) Creates a new timer. -
Method Summary
Modifier and TypeMethodDescriptionvoidshutdown()Starts the shutdown process.voidWaits for shutdown to completevoidwaitForShutdown(long timeoutInMs) Waits for shutdown to complete with a timeoutMethods inherited from class io.netty.util.HashedWheelTimer
finalize, newTimeout, pendingTimeouts, start, stop
-
Constructor Details
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer()Creates a new timer with the default thread factory (Executors.defaultThreadFactory()), default tick duration, and default number of ticks per wheel. -
ShutdownableHashedWheelTimer
Creates a new timer with the default thread factory (Executors.defaultThreadFactory()) and default number of ticks per wheel.- Parameters:
tickDuration- the duration between tickunit- the time unit of thetickDuration- Throws:
NullPointerException- ifunitisnullIllegalArgumentException- iftickDurationis <= 0
-
ShutdownableHashedWheelTimer
Creates a new timer with the default thread factory (Executors.defaultThreadFactory()).- Parameters:
tickDuration- the duration between tickunit- the time unit of thetickDurationticksPerWheel- the size of the wheel- Throws:
NullPointerException- ifunitisnullIllegalArgumentException- if either oftickDurationandticksPerWheelis <= 0
-
ShutdownableHashedWheelTimer
Creates a new timer with the default tick duration and default number of ticks per wheel.- Parameters:
threadFactory- aThreadFactorythat creates a backgroundThreadwhich is dedicated toTimerTaskexecution.- Throws:
NullPointerException- ifthreadFactoryisnull
-
ShutdownableHashedWheelTimer
Creates a new timer with the default number of ticks per wheel.- Parameters:
threadFactory- aThreadFactorythat creates a backgroundThreadwhich is dedicated toTimerTaskexecution.tickDuration- the duration between tickunit- the time unit of thetickDuration- Throws:
NullPointerException- if either ofthreadFactoryandunitisnullIllegalArgumentException- iftickDurationis <= 0
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel) Creates a new timer.- Parameters:
threadFactory- aThreadFactorythat creates a backgroundThreadwhich is dedicated toTimerTaskexecution.tickDuration- the duration between tickunit- the time unit of thetickDurationticksPerWheel- the size of the wheel- Throws:
NullPointerException- if either ofthreadFactoryandunitisnullIllegalArgumentException- if either oftickDurationandticksPerWheelis <= 0
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel, boolean leakDetection) Creates a new timer.- Parameters:
threadFactory- aThreadFactorythat creates a backgroundThreadwhich is dedicated toTimerTaskexecution.tickDuration- the duration between tickunit- the time unit of thetickDurationticksPerWheel- the size of the wheelleakDetection-trueif leak detection should be enabled always, if false it will only be enabled if the worker thread is not a daemon thread.- Throws:
NullPointerException- if either ofthreadFactoryandunitisnullIllegalArgumentException- if either oftickDurationandticksPerWheelis <= 0
-
-
Method Details
-
shutdown
public void shutdown()Description copied from interface:ShutdownableStarts the shutdown process. It is recommended to perform the actual shutdown activity in a separate thread from the thread that calls shutdown- Specified by:
shutdownin interfaceShutdownable
-
waitForShutdown
Description copied from interface:ShutdownableWaits for shutdown to complete- Specified by:
waitForShutdownin interfaceShutdownable- Throws:
InterruptedException- when the wait is interruptedIllegalStateException- when the method is invoked when the shutdown has yet to be started
-
waitForShutdown
public void waitForShutdown(long timeoutInMs) throws InterruptedException, IllegalStateException, TimeoutException Description copied from interface:ShutdownableWaits for shutdown to complete with a timeout- Specified by:
waitForShutdownin interfaceShutdownable- Parameters:
timeoutInMs- number of milliseconds to wait before throwing TimeoutException- Throws:
InterruptedException- when the wait is interruptedIllegalStateException- when the method is invoked when the shutdown has yet to be startedTimeoutException- when the operation times out
-