public class CancellableTimer extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
CancellableTimer.ScheduledEventHandler |
Constructor and Description |
---|
CancellableTimer(@NotNull EventLoop eventLoop) |
CancellableTimer(@NotNull EventLoop eventLoop,
@NotNull TimeProvider timeProvider) |
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 task is run onpublic CancellableTimer(@NotNull @NotNull EventLoop eventLoop, @NotNull @NotNull TimeProvider timeProvider)
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 © 2023. All rights reserved.