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
ConstructorDescriptionCreates 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 TypeMethodDescriptionvoid
shutdown()
Starts the shutdown process.void
Waits for shutdown to completevoid
waitForShutdown
(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
- ifunit
isnull
IllegalArgumentException
- iftickDuration
is <= 0
-
ShutdownableHashedWheelTimer
Creates a new timer with the default thread factory (Executors.defaultThreadFactory()
).- Parameters:
tickDuration
- the duration between tickunit
- the time unit of thetickDuration
ticksPerWheel
- the size of the wheel- Throws:
NullPointerException
- ifunit
isnull
IllegalArgumentException
- if either oftickDuration
andticksPerWheel
is <= 0
-
ShutdownableHashedWheelTimer
Creates a new timer with the default tick duration and default number of ticks per wheel.- Parameters:
threadFactory
- aThreadFactory
that creates a backgroundThread
which is dedicated toTimerTask
execution.- Throws:
NullPointerException
- ifthreadFactory
isnull
-
ShutdownableHashedWheelTimer
Creates a new timer with the default number of ticks per wheel.- Parameters:
threadFactory
- aThreadFactory
that creates a backgroundThread
which is dedicated toTimerTask
execution.tickDuration
- the duration between tickunit
- the time unit of thetickDuration
- Throws:
NullPointerException
- if either ofthreadFactory
andunit
isnull
IllegalArgumentException
- iftickDuration
is <= 0
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel) Creates a new timer.- Parameters:
threadFactory
- aThreadFactory
that creates a backgroundThread
which is dedicated toTimerTask
execution.tickDuration
- the duration between tickunit
- the time unit of thetickDuration
ticksPerWheel
- the size of the wheel- Throws:
NullPointerException
- if either ofthreadFactory
andunit
isnull
IllegalArgumentException
- if either oftickDuration
andticksPerWheel
is <= 0
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel, boolean leakDetection) Creates a new timer.- Parameters:
threadFactory
- aThreadFactory
that creates a backgroundThread
which is dedicated toTimerTask
execution.tickDuration
- the duration between tickunit
- the time unit of thetickDuration
ticksPerWheel
- the size of the wheelleakDetection
-true
if 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 ofthreadFactory
andunit
isnull
IllegalArgumentException
- if either oftickDuration
andticksPerWheel
is <= 0
-
-
Method Details
-
shutdown
public void shutdown()Description copied from interface:Shutdownable
Starts the shutdown process. It is recommended to perform the actual shutdown activity in a separate thread from the thread that calls shutdown- Specified by:
shutdown
in interfaceShutdownable
-
waitForShutdown
Description copied from interface:Shutdownable
Waits for shutdown to complete- Specified by:
waitForShutdown
in 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:Shutdownable
Waits for shutdown to complete with a timeout- Specified by:
waitForShutdown
in 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
-