|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthu.mta.sztaki.lpds.cloud.simulator.DeferredEvent
public abstract class DeferredEvent
Offers the event handling mechanism for non-recurring but time dependent events. Implementors should provide an implementation of the event action function which will be called once the specified ticks pass. Aggregates the events that should happen at a single time instance. This approach allows that only one Timed event is registered for a bunch of non-recurring events.
Nested Class Summary | |
---|---|
private static class |
DeferredEvent.AggregatedEventDispatcher
handles the event aggregations, actual subscriptions to timed events and dispatches the events if Timed notifies for time instance at which the non-recurring events should be fired Improves the performance of deferred events significantly if multiple events should occur at once |
Field Summary | |
---|---|
private boolean |
cancelled
Shows if the event in question was cancelled by the user |
private static DeferredEvent.AggregatedEventDispatcher |
dispatcherSingleton
the aggregator that handles the event list stored in toSweep. |
private long |
eventArrival
The time instance at which this event should be delivered |
private boolean |
received
Shows if the event was dispatched already |
private static gnu.trove.map.hash.TLongObjectHashMap<org.apache.commons.lang3.tuple.MutablePair<Integer,DeferredEvent[]>> |
toSweep
All deferred events that are due in the future are listed here. |
Constructor Summary | |
---|---|
DeferredEvent(long delay)
Allows constructing objects that will receive an eventAction() call from Timed after delay ticks. |
Method Summary | |
---|---|
void |
cancel()
If the call for eventAction() is no longer necessary at the previously specified time then the user can cancel this call to arrive with this function. |
protected abstract void |
eventAction()
When creating a deferred event, implement this function for the actual event handling mechanism of yours. |
boolean |
isCancelled()
Allows to determine whether the actual event was cancelled already or not. |
(package private) static void |
reset()
Allows the cleanup of all events registered with the aggregator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final gnu.trove.map.hash.TLongObjectHashMap<org.apache.commons.lang3.tuple.MutablePair<Integer,DeferredEvent[]>> toSweep
private static final DeferredEvent.AggregatedEventDispatcher dispatcherSingleton
private boolean cancelled
private boolean received
private final long eventArrival
Constructor Detail |
---|
public DeferredEvent(long delay)
delay
- the number of ticks that should pass before this deferred
event object's eventAction() will be called.Method Detail |
---|
public void cancel()
public boolean isCancelled()
protected abstract void eventAction()
static void reset()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |