Class 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

      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 complete
      void waitForShutdown​(long timeoutInMs)
      Waits for shutdown to complete with a timeout
      • Methods inherited from class io.netty.util.HashedWheelTimer

        finalize, newTimeout, pendingTimeouts, start, stop
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 tick
        unit - the time unit of the tickDuration
        Throws:
        java.lang.NullPointerException - if unit is null
        java.lang.IllegalArgumentException - if tickDuration 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 tick
        unit - the time unit of the tickDuration
        ticksPerWheel - the size of the wheel
        Throws:
        java.lang.NullPointerException - if unit is null
        java.lang.IllegalArgumentException - if either of tickDuration and ticksPerWheel 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 - a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.
        Throws:
        java.lang.NullPointerException - if threadFactory is null
      • 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 - a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.
        tickDuration - the duration between tick
        unit - the time unit of the tickDuration
        Throws:
        java.lang.NullPointerException - if either of threadFactory and unit is null
        java.lang.IllegalArgumentException - if tickDuration 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 - a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.
        tickDuration - the duration between tick
        unit - the time unit of the tickDuration
        ticksPerWheel - the size of the wheel
        Throws:
        java.lang.NullPointerException - if either of threadFactory and unit is null
        java.lang.IllegalArgumentException - if either of tickDuration and ticksPerWheel 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 - a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.
        tickDuration - the duration between tick
        unit - the time unit of the tickDuration
        ticksPerWheel - the size of the wheel
        leakDetection - 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 of threadFactory and unit is null
        java.lang.IllegalArgumentException - if either of tickDuration and ticksPerWheel 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 interface Shutdownable
      • 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 interface Shutdownable
        Throws:
        java.lang.InterruptedException - when the wait is interrupted
        java.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 interface Shutdownable
        Parameters:
        timeoutInMs - number of milliseconds to wait before throwing TimeoutException
        Throws:
        java.lang.InterruptedException - when the wait is interrupted
        java.lang.IllegalStateException - when the method is invoked when the shutdown has yet to be started
        java.util.concurrent.TimeoutException - when the operation times out