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
-
-
Constructor Summary
Constructors Constructor Description ShutdownableHashedWheelTimer()Creates a new timer with the default thread factory (Executors.defaultThreadFactory()), default tick duration, and default number of ticks per wheel.ShutdownableHashedWheelTimer(long tickDuration, java.util.concurrent.TimeUnit unit)Creates a new timer with the default thread factory (Executors.defaultThreadFactory()) and default number of ticks per wheel.ShutdownableHashedWheelTimer(long tickDuration, java.util.concurrent.TimeUnit unit, int ticksPerWheel)Creates a new timer with the default thread factory (Executors.defaultThreadFactory()).ShutdownableHashedWheelTimer(java.util.concurrent.ThreadFactory threadFactory)Creates a new timer with the default tick duration and default number of ticks per wheel.ShutdownableHashedWheelTimer(java.util.concurrent.ThreadFactory threadFactory, long tickDuration, java.util.concurrent.TimeUnit unit)Creates a new timer with the default number of ticks per wheel.ShutdownableHashedWheelTimer(java.util.concurrent.ThreadFactory threadFactory, long tickDuration, java.util.concurrent.TimeUnit unit, int ticksPerWheel)Creates a new timer.ShutdownableHashedWheelTimer(java.util.concurrent.ThreadFactory threadFactory, long tickDuration, java.util.concurrent.TimeUnit unit, int ticksPerWheel, boolean leakDetection)Creates a new timer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidshutdown()Starts the shutdown process.voidwaitForShutdown()Waits for shutdown to completevoidwaitForShutdown(long timeoutInMs)Waits for shutdown to complete with a timeout
-
-
-
Constructor Detail
-
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
public ShutdownableHashedWheelTimer(long tickDuration, java.util.concurrent.TimeUnit unit)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:
java.lang.NullPointerException- ifunitisnulljava.lang.IllegalArgumentException- iftickDurationis <= 0
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer(long tickDuration, java.util.concurrent.TimeUnit unit, int ticksPerWheel)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:
java.lang.NullPointerException- ifunitisnulljava.lang.IllegalArgumentException- if either oftickDurationandticksPerWheelis <= 0
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer(java.util.concurrent.ThreadFactory threadFactory)
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:
java.lang.NullPointerException- ifthreadFactoryisnull
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer(java.util.concurrent.ThreadFactory threadFactory, long tickDuration, java.util.concurrent.TimeUnit unit)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:
java.lang.NullPointerException- if either ofthreadFactoryandunitisnulljava.lang.IllegalArgumentException- iftickDurationis <= 0
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer(java.util.concurrent.ThreadFactory threadFactory, long tickDuration, java.util.concurrent.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:
java.lang.NullPointerException- if either ofthreadFactoryandunitisnulljava.lang.IllegalArgumentException- if either oftickDurationandticksPerWheelis <= 0
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer(java.util.concurrent.ThreadFactory threadFactory, long tickDuration, java.util.concurrent.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:
java.lang.NullPointerException- if either ofthreadFactoryandunitisnulljava.lang.IllegalArgumentException- if either oftickDurationandticksPerWheelis <= 0
-
-
Method Detail
-
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
public void waitForShutdown() throws java.lang.InterruptedException, java.lang.IllegalStateExceptionDescription copied from interface:ShutdownableWaits for shutdown to complete- Specified by:
waitForShutdownin interfaceShutdownable- Throws:
java.lang.InterruptedException- when the wait is interruptedjava.lang.IllegalStateException- when the method is invoked when the shutdown has yet to be started
-
waitForShutdown
public void waitForShutdown(long timeoutInMs) throws java.lang.InterruptedException, java.lang.IllegalStateException, java.util.concurrent.TimeoutExceptionDescription 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:
java.lang.InterruptedException- when the wait is interruptedjava.lang.IllegalStateException- when the method is invoked when the shutdown has yet to be startedjava.util.concurrent.TimeoutException- when the operation times out
-
-