public class HashWheelTimer extends 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<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(String name,
int res,
int wheelSize,
HashWheelTimer.WaitStrategy strategy,
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<Long> consumer,
long period,
TimeUnit timeUnit)
Schedule a recurring task.
|
Pausable |
schedule(Consumer<Long> consumer,
long period,
TimeUnit timeUnit,
long delayInMilliseconds)
Schedule a recurring task.
|
void |
start()
Start the Timer
|
Pausable |
submit(Consumer<Long> consumer)
Submit a task for arbitrary execution after the delay of this timer's resolution.
|
Pausable |
submit(Consumer<Long> consumer,
long period,
TimeUnit timeUnit)
Submit a task for arbitrary execution after the given time delay.
|
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(String name, int res, int wheelSize, HashWheelTimer.WaitStrategy strategy, 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()
Timer
getResolution
in interface Timer
public Pausable schedule(Consumer<Long> consumer, long period, TimeUnit timeUnit, long delayInMilliseconds)
Timer
Consumer
will be invoked once every N time units
after the given delay.schedule
in interface Timer
consumer
- the Consumer
to invoke each periodperiod
- the amount of time that should elapse between invocations of the given Consumer
timeUnit
- the unit of time the period
is to be measured indelayInMilliseconds
- a number of milliseconds in which to delay any execution of the given Consumer
Pausable
that can be used to cancel
, pause
or
resume
the given task.public Pausable submit(Consumer<Long> consumer, long period, TimeUnit timeUnit)
Timer
submit
in interface Timer
consumer
- the Consumer
to invokeperiod
- the amount of time that should elapse before invocations of the given Consumer
timeUnit
- 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<Long> consumer)
Timer
public Pausable schedule(Consumer<Long> consumer, long period, TimeUnit timeUnit)
Timer
Consumer
will be invoked immediately, as well as
once
every N time units.schedule
in interface Timer
consumer
- the Consumer
to invoke each periodperiod
- the amount of time that should elapse between invocations of the given Consumer
timeUnit
- 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()
Copyright © 2017. All rights reserved.