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 void
shutdown()
Starts the shutdown process.void
waitForShutdown()
Waits for shutdown to completevoid
waitForShutdown(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
- ifunit
isnull
java.lang.IllegalArgumentException
- iftickDuration
is <= 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 thetickDuration
ticksPerWheel
- the size of the wheel- Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- if either oftickDuration
andticksPerWheel
is <= 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
- aThreadFactory
that creates a backgroundThread
which is dedicated toTimerTask
execution.- Throws:
java.lang.NullPointerException
- ifthreadFactory
isnull
-
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
- aThreadFactory
that creates a backgroundThread
which is dedicated toTimerTask
execution.tickDuration
- the duration between tickunit
- the time unit of thetickDuration
- Throws:
java.lang.NullPointerException
- if either ofthreadFactory
andunit
isnull
java.lang.IllegalArgumentException
- iftickDuration
is <= 0
-
ShutdownableHashedWheelTimer
public ShutdownableHashedWheelTimer(java.util.concurrent.ThreadFactory threadFactory, long tickDuration, java.util.concurrent.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:
java.lang.NullPointerException
- if either ofthreadFactory
andunit
isnull
java.lang.IllegalArgumentException
- if either oftickDuration
andticksPerWheel
is <= 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
- 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:
java.lang.NullPointerException
- if either ofthreadFactory
andunit
isnull
java.lang.IllegalArgumentException
- if either oftickDuration
andticksPerWheel
is <= 0
-
-
Method Detail
-
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
public void waitForShutdown() throws java.lang.InterruptedException, java.lang.IllegalStateException
Description copied from interface:Shutdownable
Waits for shutdown to complete- Specified by:
waitForShutdown
in 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.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:
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
-
-