A InternalTimer optimized for approximated I/O timeout scheduling. ===Tick Duration=== As described with 'approximated', this timer does not execute the scheduled TimerTask on time. HashedWheelTimer, on every tick, will check if there are any TimerTasks behind the schedule and execute them.
You can increase or decrease the accuracy of the execution timing by specifying smaller or larger tick duration in the constructor. In most network applications, I/O timeout does not need to be accurate. Therefore, the default tick duration is 100 milliseconds, and you will not need to try different configurations in most cases. ===Ticks per Wheel (Wheel Size)=== HashedWheelTimer maintains a data structure called 'wheel'. To put simply, a wheel is a hash table of TimerTasks whose hash function is 'deadline of the task'. The default number of ticks per wheel (i.e. the size of the wheel) is 512. You could specify a larger value if you are going to schedule a lot of timeouts. ===Do not create many instances.=== HashedWheelTimer creates a new thread whenever it is instantiated and started. Therefore, you should make sure to create only one instance and share it across your application. One of the common mistakes, that makes your application unresponsive, is to create a new instance for every connection. ===Implementation Details=== HashedWheelTimer is based on George Varghese and Tony Lauck's paper, 'Hashed and Hierarchical Timing Wheels: data structures to efficiently implement a timer facility'. More comprehensive slides are located here.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait InternalTimerclass AtomicIntegerclass Numbertrait Serializableclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Schedules the specified TimerTask for one-time execution after the specified delay.
Schedules the specified TimerTask for one-time execution after the specified delay.
Value parameters
- delay
-
one-time execution delay.
- task
-
task to execute.
- unit
-
one-time execution delay time unit.
Attributes
- Returns
-
a handle which is associated with the specified task
- Throws
-
IllegalStateException
if this timer has been stop stopped already
RejectedExecutionExceptionif the pending timeouts are too many and creating new timeout can cause instability in the system.
- Definition Classes
Schedules the specified TimerTask for one-time execution after the specified delay and then periodic execution with period delay.
Schedules the specified TimerTask for one-time execution after the specified delay and then periodic execution with period delay.
Value parameters
- delay
-
one-time execution delay.
- period
-
periodic execution delay.
- punit
-
periodic execution delay time unit.
- task
-
task to execute.
- unit
-
one-time execution delay time unit.
Attributes
- Returns
-
a handle which is associated with the specified task
- Throws
-
IllegalStateException
if this timer has been stop stopped already
RejectedExecutionExceptionif the pending timeouts are too many and creating new timeout can cause instability in the system.
- Definition Classes
Starts the background thread explicitly. The background thread will start automatically on demand even if you did not call this method.
Starts the background thread explicitly. The background thread will start automatically on demand even if you did not call this method.
Attributes
- Throws
-
IllegalStateException
if this timer has been stop stopped already
Releases all resources acquired by this InternalTimer and cancels all tasks which were scheduled but not executed yet.
Releases all resources acquired by this InternalTimer and cancels all tasks which were scheduled but not executed yet.
Attributes
- Returns
-
the handles associated with the tasks which were canceled by this method
- Definition Classes
Inherited methods
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- Number
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- Number
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
Attributes
- Returns
-
a string representation of the object.
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Attributes
- Inherited from:
- AtomicInteger
Deprecated and Inherited methods
Attributes
- Deprecated
-
[Since version ]see corresponding Javadoc for more information. - Inherited from:
- AtomicInteger