public class CancellableTimer extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
CancellableTimer.ScheduledEventHandler |
| Constructor and Description |
|---|
CancellableTimer(@NotNull EventLoop eventLoop)
Constructs a CancellableTimer with the given event loop and system time provider.
|
CancellableTimer(@NotNull EventLoop eventLoop,
@NotNull TimeProvider timeProvider)
Constructs a CancellableTimer with the given event loop and custom time provider.
|
| Modifier and Type | Method and Description |
|---|---|
Closeable |
schedule(@NotNull Runnable eventHandler,
long initialDelayMs)
Schedule a handler to run once after a delay
|
Closeable |
scheduleAtFixedRate(@NotNull VanillaEventHandler eventHandler,
long initialDelayMs,
long periodMs)
uses the event loop thread to call the event handler periodically, the time that the event is
called back is best-effort, but if the thread is busy that call back maybe delayed
|
Closeable |
scheduleAtFixedRate(@NotNull VanillaEventHandler eventHandler,
long initialDelayMs,
long periodMs,
HandlerPriority priority)
uses the event loop thread to call the event handler periodically, the time that the event is
called back is best-effort, but if the thread is busy that call back maybe delayed
|
public CancellableTimer(@NotNull
@NotNull EventLoop eventLoop)
eventLoop - the event loop that the timer tasks will run on.public CancellableTimer(@NotNull
@NotNull EventLoop eventLoop,
@NotNull
@NotNull TimeProvider timeProvider)
eventLoop - the event loop that the timer tasks will run on.timeProvider - the custom time provider to use for scheduling.public Closeable scheduleAtFixedRate(@NotNull @NotNull VanillaEventHandler eventHandler, long initialDelayMs, long periodMs)
eventHandler - the handler to be called backinitialDelayMs - how long in milliseconds to wait before being called backperiodMs - the poll interval of being calledCloseable that when closed will abort any remaining scheduled callspublic Closeable scheduleAtFixedRate(@NotNull @NotNull VanillaEventHandler eventHandler, long initialDelayMs, long periodMs, HandlerPriority priority)
eventHandler - the handler to be called backinitialDelayMs - how long in milliseconds to wait before being called backperiodMs - the poll interval of being calledpriority - the priority of the event handlerCloseable that when closed will abort any remaining scheduled callspublic Closeable schedule(@NotNull @NotNull Runnable eventHandler, long initialDelayMs)
eventHandler - the handler to be called backinitialDelayMs - how long in milliseconds to wait before being called backCloseable that when closed will abort any remaining scheduled callsCopyright © 2024. All rights reserved.