java.lang.Object com.realtime.crossfire.jxclient.items.EventScheduler
public class EventScheduler
A scheduler for synchronous event notifications. Notifications are triggered
by calling 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
.
Field Summary | |
---|---|
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 Summary | |
---|---|
EventScheduler(int delay,
int afterEventDelay,
java.lang.Runnable eventSchedulerCallback)
Creates a new instance. |
Method Summary | |
---|---|
void |
start()
Activates this instance. |
void |
trigger()
Notifies the callback. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
.
Constructor Detail |
---|
public EventScheduler(int delay, int afterEventDelay, @NotNull java.lang.Runnable eventSchedulerCallback)
delay
- the initial delayafterEventDelay
- the "after-event" delayeventSchedulerCallback
- the callback to notifyMethod Detail |
---|
public void start()
public void trigger()