public class EventScheduler
extends java.lang.Object
trigger()
. Notifications are delivered by calling the
event scheduler callback of eventSchedulerCallback
. This callback is
called delay
after the last call to trigger()
but not
faster than once per eventSchedulerCallback
.Modifier and Type | Field and Description |
---|---|
private int |
afterEventDelay
The minimum delay between two
eventSchedulerCallback
notifications. |
private int |
delay
The delay between a call to
trigger() until the eventSchedulerCallback is notified. |
private java.lang.Runnable |
eventSchedulerCallback
The
Runnable to notify. |
private long |
nextAction
The timestamp for the next notification.
|
private long |
nextActionNotBefore
The minimum timestamp for the next notification.
|
private java.lang.Runnable |
runnable
The
Runnable delivering notifications through eventSchedulerCallback . |
private java.lang.Object |
sync
The object used to synchronize access to
nextAction and nextActionNotBefore . |
private java.lang.Thread |
thread
The thread running
runnable . |
Constructor and Description |
---|
EventScheduler(int delay,
int afterEventDelay,
java.lang.Runnable eventSchedulerCallback)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
start()
Activates this instance.
|
void |
trigger()
Notifies the callback.
|
private final int afterEventDelay
eventSchedulerCallback
notifications.private final int delay
trigger()
until the eventSchedulerCallback
is notified.@NotNull private final java.lang.Runnable eventSchedulerCallback
Runnable
to notify.private long nextAction
0
when not
active.private long nextActionNotBefore
@NotNull private final java.lang.Runnable runnable
Runnable
delivering notifications through eventSchedulerCallback
.@NotNull private final java.lang.Object sync
nextAction
and nextActionNotBefore
.@NotNull private final java.lang.Thread thread
runnable
.