cc.otavia.core.timer

Members list

Type members

Classlikes

class HashedWheelTimer(val system: ActorSystem, threadFactory: ThreadFactory, val tickDuration: Long, unit: TimeUnit, val ticksPerWheel: Int, leakDetection: Boolean, maxPendingTimeouts: Long, taskExecutor: Executor) extends AtomicInteger, InternalTimer

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.

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 'dead line 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.

Value parameters

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.

maxPendingTimeouts

The maximum number of pending timeouts after which call to newTimeout will result in java.util.concurrent.RejectedExecutionException being thrown. No maximum pending timeouts limit is assumed if this value is 0 or negative.

system

ActorSystem of the HashedWheelTimer belong.

taskExecutor

The Executor that is used to execute the submitted TimerTasks. The caller is responsible to shutdown the Executor once it is not needed anymore.

threadFactory

a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.

tickDuration

the duration between tick

ticksPerWheel

the size of the wheel

unit

the time unit of the tickDuration

Attributes

Throws
IllegalArgumentException

if either of tickDuration and ticksPerWheel is <= 0

NullPointerException

if either of threadFactory and unit is null

Constructor

Creates a new HashedWheelTimer.

Companion
object
Supertypes
class AtomicInteger
class Number
trait Serializable
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
object ImmediateExecutor extends Executor

Executor which execute tasks in the callers thread.

Executor which execute tasks in the callers thread.

Attributes

Supertypes
trait Executor
class Object
trait Matchable
class Any
Self type

Schedules TimerTasks for one-time future execution in a background thread.

Schedules TimerTasks for one-time future execution in a background thread.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Timeout

A handle associated with a TimerTask that is returned by a InternalTimer.

A handle associated with a TimerTask that is returned by a InternalTimer.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
sealed trait TimeoutTrigger

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class DelayPeriod
class DelayTime
class FixTime

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
trait Timer

Timer can generate timeout event.

Timer can generate timeout event.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class TimerImpl
object Timer

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Timer.type
final class TimerImpl(val system: ActorSystem) extends Timer

Default implementation of Timer

Default implementation of Timer

Attributes

Supertypes
trait Timer
class Object
trait Matchable
class Any
trait TimerTask

A task which is executed after the delay specified with long, TimeUnit).

A task which is executed after the delay specified with long, TimeUnit).

Attributes

Supertypes
class Object
trait Matchable
class Any
class TimerTaskManager(val timer: Timer)

Attributes

Supertypes
class Object
trait Matchable
class Any