Top Description Inners Fields Constructors Methods
io.netty5.util

public Class HashedWheelTimer

extends Object
implements Timer
Class Inheritance
All Implemented Interfaces
io.netty5.util.Timer
Imports
io.netty5.util.concurrent.ImmediateExecutor, io.netty5.util.internal.PlatformDependent, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.util.Collections, .HashSet, .Queue, .Set, java.util.concurrent.CountDownLatch, .Executor, .Executors, .RejectedExecutionException, .ThreadFactory, .TimeUnit, java.util.concurrent.atomic.AtomicBoolean, .AtomicInteger, .AtomicIntegerFieldUpdater, .AtomicLong

A Timer 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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
HashedWheelTimer.HashedWheelBucket

Bucket that stores HashedWheelTimeouts.

private static class
private class

Field Summary

Modifier and TypeField and Description
private final Queue<HashedWheelTimer.HashedWheelTimeout>
private static final int
private static final AtomicInteger
private final ResourceLeakTracker<HashedWheelTimer>
private static final ResourceLeakDetector<HashedWheelTimer>
pack-priv static final InternalLogger
private final int
private final long
private static final long
private final AtomicLong
private volatile long
private final CountDownLatch
private final Executor
private final long
private final Queue<HashedWheelTimer.HashedWheelTimeout>
private static final AtomicBoolean
private final HashedWheelTimer.HashedWheelBucket[]
private final HashedWheelTimer.Worker
public static final int
public static final int
public static final int
private static final AtomicIntegerFieldUpdater<HashedWheelTimer>
private volatile int
private final Thread

Constructor Summary

AccessConstructor and Description
public
HashedWheelTimer()

Creates a new timer with the default thread factory (Executors#defaultThreadFactory()), default tick duration, and default number of ticks per wheel.

public
HashedWheelTimer(long
the duration between tick
tickDuration
,
TimeUnit
the time unit of the tickDuration
unit
)

Creates a new timer with the default thread factory (Executors#defaultThreadFactory()) and default number of ticks per wheel.

public
HashedWheelTimer(long
the duration between tick
tickDuration
,
TimeUnit
the time unit of the tickDuration
unit
,
int
the size of the wheel
ticksPerWheel
)

Creates a new timer with the default thread factory (Executors#defaultThreadFactory()).

public
HashedWheelTimer(ThreadFactory
a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.
threadFactory
)

Creates a new timer with the default tick duration and default number of ticks per wheel.

public
HashedWheelTimer(ThreadFactory
a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.
threadFactory
,
long
the duration between tick
tickDuration
,
TimeUnit
the time unit of the tickDuration
unit
)

Creates a new timer with the default number of ticks per wheel.

public
HashedWheelTimer(ThreadFactory
a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.
threadFactory
,
long
the duration between tick
tickDuration
,
TimeUnit
the time unit of the tickDuration
unit
,
int
the size of the wheel
ticksPerWheel
)

Creates a new timer.

public
HashedWheelTimer(ThreadFactory
a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.
threadFactory
,
long
the duration between tick
tickDuration
,
TimeUnit
the time unit of the tickDuration
unit
,
int
the size of the wheel
ticksPerWheel
,
boolean
true if leak detection should be enabled always, if false it will only be enabled if the worker thread is not a daemon thread.
leakDetection
)

Creates a new timer.

public
HashedWheelTimer(ThreadFactory
a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.
threadFactory
,
long
the duration between tick
tickDuration
,
TimeUnit
the time unit of the tickDuration
unit
,
int
the size of the wheel
ticksPerWheel
,
boolean
true if leak detection should be enabled always, if false it will only be enabled if the worker thread is not a daemon thread.
leakDetection
,
long
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.
maxPendingTimeouts
)

Creates a new timer.

public
HashedWheelTimer(ThreadFactory
a ThreadFactory that creates a background Thread which is dedicated to TimerTask execution.
threadFactory
,
long
the duration between tick
tickDuration
,
TimeUnit
the time unit of the tickDuration
unit
,
int
the size of the wheel
ticksPerWheel
,
boolean
true if leak detection should be enabled always, if false it will only be enabled if the worker thread is not a daemon thread.
leakDetection
,
long
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.
maxPendingTimeouts
,
Executor
The Executor that is used to execute the submitted TimerTasks. The caller is responsible to shutdown the Executor once it is not needed anymore.
taskExecutor
)

Creates a new timer.

Method Summary

Modifier and TypeMethod and Description
private static HashedWheelTimer.HashedWheelBucket[]
createWheel(int ticksPerWheel)

protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
public Timeout
newTimeout(TimerTask task, long delay, TimeUnit unit)

Implements io.netty5.util.Timer.newTimeout.

Schedules the specified TimerTask for one-time execution after the specified delay.
private static int
normalizeTicksPerWheel(int ticksPerWheel)

public long
pendingTimeouts()

Returns the number of pending timeouts of this Timer.

private static void
public void
start()

Starts the background thread explicitly.

public Set<Timeout>
stop()

Implements io.netty5.util.Timer.stop.

Releases all resources acquired by this Timer and cancels all tasks which were scheduled but not executed yet.
Inherited from java.lang.Object:
cloneequalsgetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cancelledTimeoutsback to summary
private final Queue<HashedWheelTimer.HashedWheelTimeout> cancelledTimeouts
INSTANCE_COUNT_LIMITback to summary
private static final int INSTANCE_COUNT_LIMIT
INSTANCE_COUNTERback to summary
private static final AtomicInteger INSTANCE_COUNTER
leakback to summary
private final ResourceLeakTracker<HashedWheelTimer> leak
leakDetectorback to summary
private static final ResourceLeakDetector<HashedWheelTimer> leakDetector
loggerback to summary
pack-priv static final InternalLogger logger
maskback to summary
private final int mask
maxPendingTimeoutsback to summary
private final long maxPendingTimeouts
MILLISECOND_NANOSback to summary
private static final long MILLISECOND_NANOS
pendingTimeoutsback to summary
private final AtomicLong pendingTimeouts
startTimeback to summary
private volatile long startTime
startTimeInitializedback to summary
private final CountDownLatch startTimeInitialized
taskExecutorback to summary
private final Executor taskExecutor
tickDurationback to summary
private final long tickDuration
timeoutsback to summary
private final Queue<HashedWheelTimer.HashedWheelTimeout> timeouts
WARNED_TOO_MANY_INSTANCESback to summary
private static final AtomicBoolean WARNED_TOO_MANY_INSTANCES
wheelback to summary
private final HashedWheelTimer.HashedWheelBucket[] wheel
workerback to summary
private final HashedWheelTimer.Worker worker
WORKER_STATE_INITback to summary
public static final int WORKER_STATE_INIT
WORKER_STATE_SHUTDOWNback to summary
public static final int WORKER_STATE_SHUTDOWN
WORKER_STATE_STARTEDback to summary
public static final int WORKER_STATE_STARTED
WORKER_STATE_UPDATERback to summary
private static final AtomicIntegerFieldUpdater<HashedWheelTimer> WORKER_STATE_UPDATER
workerStateback to summary
private volatile int workerState
Annotations
@SuppressWarnings:unused, FieldMayBeFinal
workerThreadback to summary
private final Thread workerThread

Constructor Detail

HashedWheelTimerback to summary
public HashedWheelTimer()

Creates a new timer with the default thread factory (Executors#defaultThreadFactory()), default tick duration, and default number of ticks per wheel.

HashedWheelTimerback to summary
public HashedWheelTimer(long tickDuration, TimeUnit unit)

Creates a new timer with the default thread factory (Executors#defaultThreadFactory()) and default number of ticks per wheel.

Parameters
tickDuration:long

the duration between tick

unit:TimeUnit

the time unit of the tickDuration

Exceptions
NullPointerException:
if unit is null
IllegalArgumentException:
if tickDuration is <= 0
HashedWheelTimerback to summary
public HashedWheelTimer(long tickDuration, TimeUnit unit, int ticksPerWheel)

Creates a new timer with the default thread factory (Executors#defaultThreadFactory()).

Parameters
tickDuration:long

the duration between tick

unit:TimeUnit

the time unit of the tickDuration

ticksPerWheel:int

the size of the wheel

Exceptions
NullPointerException:
if unit is null
IllegalArgumentException:
if either of tickDuration and ticksPerWheel is <= 0
HashedWheelTimerback to summary
public HashedWheelTimer(ThreadFactory threadFactory)

Creates a new timer with the default tick duration and default number of ticks per wheel.

Parameters
threadFactory:ThreadFactory

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

Exceptions
NullPointerException:
if threadFactory is null
HashedWheelTimerback to summary
public HashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit)

Creates a new timer with the default number of ticks per wheel.

Parameters
threadFactory:ThreadFactory

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

tickDuration:long

the duration between tick

unit:TimeUnit

the time unit of the tickDuration

Exceptions
NullPointerException:
if either of threadFactory and unit is null
IllegalArgumentException:
if tickDuration is <= 0
HashedWheelTimerback to summary
public HashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel)

Creates a new timer.

Parameters
threadFactory:ThreadFactory

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

tickDuration:long

the duration between tick

unit:TimeUnit

the time unit of the tickDuration

ticksPerWheel:int

the size of the wheel

Exceptions
NullPointerException:
if either of threadFactory and unit is null
IllegalArgumentException:
if either of tickDuration and ticksPerWheel is <= 0
HashedWheelTimerback to summary
public HashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel, boolean leakDetection)

Creates a new timer.

Parameters
threadFactory:ThreadFactory

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

tickDuration:long

the duration between tick

unit:TimeUnit

the time unit of the tickDuration

ticksPerWheel:int

the size of the wheel

leakDetection:boolean

true if leak detection should be enabled always, if false it will only be enabled if the worker thread is not a daemon thread.

Exceptions
NullPointerException:
if either of threadFactory and unit is null
IllegalArgumentException:
if either of tickDuration and ticksPerWheel is <= 0
HashedWheelTimerback to summary
public HashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel, boolean leakDetection, long maxPendingTimeouts)

Creates a new timer.

Parameters
threadFactory:ThreadFactory

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

tickDuration:long

the duration between tick

unit:TimeUnit

the time unit of the tickDuration

ticksPerWheel:int

the size of the wheel

leakDetection:boolean

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:long

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.

Exceptions
NullPointerException:
if either of threadFactory and unit is null
IllegalArgumentException:
if either of tickDuration and ticksPerWheel is <= 0
HashedWheelTimerback to summary
public HashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel, boolean leakDetection, long maxPendingTimeouts, Executor taskExecutor)

Creates a new timer.

Parameters
threadFactory:ThreadFactory

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

tickDuration:long

the duration between tick

unit:TimeUnit

the time unit of the tickDuration

ticksPerWheel:int

the size of the wheel

leakDetection:boolean

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:long

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.

taskExecutor:Executor

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

Exceptions
NullPointerException:
if either of threadFactory and unit is null
IllegalArgumentException:
if either of tickDuration and ticksPerWheel is <= 0

Method Detail

createWheelback to summary
private static HashedWheelTimer.HashedWheelBucket[] createWheel(int ticksPerWheel)
finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Annotations
@Override
Exceptions
Throwable:
the Exception raised by this method
newTimeoutback to summary
public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit)

Implements io.netty5.util.Timer.newTimeout.

Doc from io.netty5.util.Timer.newTimeout.

Schedules the specified TimerTask for one-time execution after the specified delay.

Returns:Timeout

a handle which is associated with the specified task

Annotations
@Override
normalizeTicksPerWheelback to summary
private static int normalizeTicksPerWheel(int ticksPerWheel)
pendingTimeoutsback to summary
public long pendingTimeouts()

Returns the number of pending timeouts of this Timer.

reportTooManyInstancesback to summary
private static void reportTooManyInstances()
startback to summary
public void start()

Starts the background thread explicitly. The background thread will start automatically on demand even if you did not call this method.

Exceptions
IllegalStateException:
if this timer has been stopped already
stopback to summary
public Set<Timeout> stop()

Implements io.netty5.util.Timer.stop.

Doc from io.netty5.util.Timer.stop.

Releases all resources acquired by this Timer and cancels all tasks which were scheduled but not executed yet.

Returns:Set<Timeout>

the handles associated with the tasks which were canceled by this method

Annotations
@Override
io.netty5.util back to summary

private final Class HashedWheelTimer.HashedWheelBucket

extends Object
Class Inheritance

Bucket that stores HashedWheelTimeouts. These are stored in a linked-list like datastructure to allow easy removal of HashedWheelTimeouts in the middle. Also the HashedWheelTimeout act as nodes themself and so no extra object creation is needed.

Field Summary

Modifier and TypeField and Description
private HashedWheelTimer.HashedWheelTimeout
private HashedWheelTimer.HashedWheelTimeout

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
public void
clearTimeouts(Set<Timeout> set)

Clear this bucket and return all not expired / cancelled Timeouts.

public void
expireTimeouts(long deadline)

Expire all HashedWheelTimeouts for the given deadline.

private HashedWheelTimer.HashedWheelTimeout
public HashedWheelTimer.HashedWheelTimeout
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headback to summary
private HashedWheelTimer.HashedWheelTimeout head
tailback to summary
private HashedWheelTimer.HashedWheelTimeout tail

Constructor Detail

HashedWheelBucketback to summary
private HashedWheelBucket()

Method Detail

addTimeoutback to summary
public void addTimeout(HashedWheelTimer.HashedWheelTimeout timeout)

Add HashedWheelTimeout to this bucket.

clearTimeoutsback to summary
public void clearTimeouts(Set<Timeout> set)

Clear this bucket and return all not expired / cancelled Timeouts.

expireTimeoutsback to summary
public void expireTimeouts(long deadline)

Expire all HashedWheelTimeouts for the given deadline.

pollTimeoutback to summary
private HashedWheelTimer.HashedWheelTimeout pollTimeout()
removeback to summary
public HashedWheelTimer.HashedWheelTimeout remove(HashedWheelTimer.HashedWheelTimeout timeout)
io.netty5.util back to summary

private final Class HashedWheelTimer.HashedWheelTimeout

extends Object
implements Timeout, Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable, io.netty5.util.Timeout

Field Summary

Modifier and TypeField and Description
pack-priv HashedWheelTimer.HashedWheelBucket
private final long
pack-priv HashedWheelTimer.HashedWheelTimeout
pack-priv HashedWheelTimer.HashedWheelTimeout
pack-priv long
private static final int
private static final int
private static final int
private volatile int
private static final AtomicIntegerFieldUpdater<HashedWheelTimer.HashedWheelTimeout>
private final TimerTask
private final HashedWheelTimer

Constructor Summary

AccessConstructor and Description
pack-priv
HashedWheelTimeout(HashedWheelTimer timer, TimerTask task, long deadline)

Method Summary

Modifier and TypeMethod and Description
public boolean
cancel()

Implements io.netty5.util.Timeout.cancel.

Attempts to cancel the TimerTask associated with this handle.
public boolean
compareAndSetState(int expected, int state)

public void
public boolean
isCancelled()

Implements io.netty5.util.Timeout.isCancelled.

Returns true if and only if the TimerTask associated with this handle has been cancelled.
public boolean
isExpired()

Implements io.netty5.util.Timeout.isExpired.

Returns true if and only if the TimerTask associated with this handle has been expired.
pack-priv void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public int
public TimerTask
task()

Implements io.netty5.util.Timeout.task.

Returns the TimerTask which is associated with this handle.
public Timer
timer()

Implements io.netty5.util.Timeout.timer.

Returns the Timer that created this handle.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bucketback to summary
pack-priv HashedWheelTimer.HashedWheelBucket bucket
deadlineback to summary
private final long deadline
nextback to summary
pack-priv HashedWheelTimer.HashedWheelTimeout next
prevback to summary
pack-priv HashedWheelTimer.HashedWheelTimeout prev
remainingRoundsback to summary
pack-priv long remainingRounds
ST_CANCELLEDback to summary
private static final int ST_CANCELLED
ST_EXPIREDback to summary
private static final int ST_EXPIRED
ST_INITback to summary
private static final int ST_INIT
stateback to summary
private volatile int state
Annotations
@SuppressWarnings:unused, FieldMayBeFinal, RedundantFieldInitialization
STATE_UPDATERback to summary
private static final AtomicIntegerFieldUpdater<HashedWheelTimer.HashedWheelTimeout> STATE_UPDATER
taskback to summary
private final TimerTask task
timerback to summary
private final HashedWheelTimer timer

Constructor Detail

HashedWheelTimeoutback to summary
pack-priv HashedWheelTimeout(HashedWheelTimer timer, TimerTask task, long deadline)

Method Detail

cancelback to summary
public boolean cancel()

Implements io.netty5.util.Timeout.cancel.

Doc from io.netty5.util.Timeout.cancel.

Attempts to cancel the TimerTask associated with this handle. If the task has been executed or cancelled already, it will return with no side effect.

Returns:boolean

True if the cancellation completed successfully, otherwise false

Annotations
@Override
compareAndSetStateback to summary
public boolean compareAndSetState(int expected, int state)
expireback to summary
public void expire()
isCancelledback to summary
public boolean isCancelled()

Implements io.netty5.util.Timeout.isCancelled.

Doc from io.netty5.util.Timeout.isCancelled.

Returns true if and only if the TimerTask associated with this handle has been cancelled.

Annotations
@Override
isExpiredback to summary
public boolean isExpired()

Implements io.netty5.util.Timeout.isExpired.

Doc from io.netty5.util.Timeout.isExpired.

Returns true if and only if the TimerTask associated with this handle has been expired.

Annotations
@Override
removeback to summary
pack-priv void remove()
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
stateback to summary
public int state()
taskback to summary
public TimerTask task()

Implements io.netty5.util.Timeout.task.

Doc from io.netty5.util.Timeout.task.

Returns the TimerTask which is associated with this handle.

Annotations
@Override
timerback to summary
public Timer timer()

Implements io.netty5.util.Timeout.timer.

Doc from io.netty5.util.Timeout.timer.

Returns the Timer that created this handle.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
io.netty5.util back to summary

private final Class HashedWheelTimer.Worker

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private long
private final Set<Timeout>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
private void
public Set<Timeout>
private long

Returns:

Long.MIN_VALUE if received a shutdown request, current time otherwise (with Long.MIN_VALUE changed by +1)
waitForNextTick
()

calculate goal nanoTime from startTime and current tick number, then wait until that goal has been reached.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

tickback to summary
private long tick
unprocessedTimeoutsback to summary
private final Set<Timeout> unprocessedTimeouts

Constructor Detail

Workerback to summary
private Worker()

Method Detail

processCancelledTasksback to summary
private void processCancelledTasks()
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
transferTimeoutsToBucketsback to summary
private void transferTimeoutsToBuckets()
unprocessedTimeoutsback to summary
public Set<Timeout> unprocessedTimeouts()
waitForNextTickback to summary
private long waitForNextTick()

calculate goal nanoTime from startTime and current tick number, then wait until that goal has been reached.

Returns:long

Long.MIN_VALUE if received a shutdown request, current time otherwise (with Long.MIN_VALUE changed by +1)