public class HashWheelTimer extends java.lang.Object implements Timer
| Modifier and Type | Class and Description |
|---|---|
static class |
HashWheelTimer.BusySpinWait
BusySpin wait strategy.
|
static class |
HashWheelTimer.SleepWait
Sleep wait strategy.
|
static class |
HashWheelTimer.TimerPausable<T extends Consumer<java.lang.Long>>
Timer Registration
|
static interface |
HashWheelTimer.WaitStrategy
Wait strategy for the timer
|
static class |
HashWheelTimer.YieldingWait
Yielding wait strategy.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_WHEEL_SIZE |
| Constructor and Description |
|---|
HashWheelTimer()
Create a new
HashWheelTimer using the given with default resolution of 100 milliseconds and
default wheel size. |
HashWheelTimer(int resolution)
Create a new
HashWheelTimer using the given timer resolution. |
HashWheelTimer(int res,
int wheelSize,
HashWheelTimer.WaitStrategy waitStrategy)
Create a new
HashWheelTimer using the given timer and . |
HashWheelTimer(java.lang.String name,
int res,
int wheelSize,
HashWheelTimer.WaitStrategy strategy,
java.util.concurrent.Executor exec)
Create a new
HashWheelTimer using the given timer and . |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancel current Timer
|
long |
getResolution()
Get the resolution of this tTimer.
|
Pausable |
schedule(Consumer<java.lang.Long> consumer,
long period,
java.util.concurrent.TimeUnit timeUnit)
Schedule a recurring task.
|
Pausable |
schedule(Consumer<java.lang.Long> consumer,
long period,
java.util.concurrent.TimeUnit timeUnit,
long delayInMilliseconds)
Schedule a recurring task.
|
void |
start()
Start the Timer
|
Pausable |
submit(Consumer<java.lang.Long> consumer)
Submit a task for arbitrary execution after the delay of this timer's resolution.
|
Pausable |
submit(Consumer<java.lang.Long> consumer,
long period,
java.util.concurrent.TimeUnit timeUnit)
Submit a task for arbitrary execution after the given time delay.
|
java.lang.String |
toString() |
public static final int DEFAULT_WHEEL_SIZE
public HashWheelTimer()
HashWheelTimer using the given with default resolution of 100 milliseconds and
default wheel size.public HashWheelTimer(int resolution)
HashWheelTimer using the given timer resolution. All times will rounded up to the closest
multiple of this resolution.resolution - the resolution of this timer, in millisecondspublic HashWheelTimer(int res,
int wheelSize,
HashWheelTimer.WaitStrategy waitStrategy)
HashWheelTimer using the given timer and . All times will
rounded up to the closest multiple of this resolution.res - resolution of this timer in millisecondswheelSize - size of the Ring Buffer supporting the Timer, the larger the wheel, the less the lookup time
is
for sparse timeouts. Sane default is 512.waitStrategy - strategy for waiting for the next tickpublic HashWheelTimer(java.lang.String name,
int res,
int wheelSize,
HashWheelTimer.WaitStrategy strategy,
java.util.concurrent.Executor exec)
HashWheelTimer using the given timer and . All times
will
rounded up to the closest multiple of this resolution.name - name for daemon thread factory to be displayedres - resolution of this timer in millisecondswheelSize - size of the Ring Buffer supporting the Timer, the larger the wheel, the less the lookup time is
for sparse timeouts. Sane default is 512.strategy - strategy for waiting for the next tickexec - Executor instance to submit tasks topublic long getResolution()
TimergetResolution in interface Timerpublic Pausable schedule(Consumer<java.lang.Long> consumer, long period, java.util.concurrent.TimeUnit timeUnit, long delayInMilliseconds)
TimerConsumer will be invoked once every N time units
after the given delay.schedule in interface Timerconsumer - the Consumer to invoke each periodperiod - the amount of time that should elapse between invocations of the given ConsumertimeUnit - the unit of time the period is to be measured indelayInMilliseconds - a number of milliseconds in which to delay any execution of the given ConsumerPausable that can be used to cancel, pause or
resume the given task.public Pausable submit(Consumer<java.lang.Long> consumer, long period, java.util.concurrent.TimeUnit timeUnit)
Timersubmit in interface Timerconsumer - the Consumer to invokeperiod - the amount of time that should elapse before invocations of the given ConsumertimeUnit - the unit of time the period is to be measured inPausable that can be used to cancel, pause or
resume the given task.public Pausable submit(Consumer<java.lang.Long> consumer)
Timerpublic Pausable schedule(Consumer<java.lang.Long> consumer, long period, java.util.concurrent.TimeUnit timeUnit)
TimerConsumer will be invoked immediately, as well as
once
every N time units.schedule in interface Timerconsumer - the Consumer to invoke each periodperiod - the amount of time that should elapse between invocations of the given ConsumertimeUnit - the unit of time the period is to be measured inPausable that can be used to cancel, pause or
resume the given task.Timer.schedule(reactor.fn.Consumer, long, java.util.concurrent.TimeUnit, long)public void start()
public java.lang.String toString()
toString in class java.lang.Object