public final class ZTimer
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ZTimer.Timer
Opaque representation of a timer.
|
Constructor and Description |
---|
ZTimer() |
ZTimer(Supplier<java.lang.Long> clock) |
Modifier and Type | Method and Description |
---|---|
ZTimer.Timer |
add(long interval,
TimerHandler handler,
java.lang.Object... args)
Add timer to the set, timer repeats forever, or until cancel is called.
|
int |
execute()
Execute the timers.
|
int |
sleepAndExecute()
Sleeps until at least one timer can be executed and execute the timers.
|
long |
timeout()
Returns the time in millisecond until the next timer.
|
private final Timers timer
public ZTimer()
ZTimer(Supplier<java.lang.Long> clock)
public ZTimer.Timer add(long interval, TimerHandler handler, java.lang.Object... args)
interval
- the interval of repetition in milliseconds.handler
- the callback called at the expiration of the timer.args
- the optional arguments for the handler.public long timeout()
public int execute()
public int sleepAndExecute()