* the state. That way, when that event leaves the queue, we will know
* for sure that the state system processed the preceding real event.
*/
- TmfTimestamp ts = new TmfTimestamp(0); /* it must not be -1! */
- TmfEvent ev = new TmfEvent(null, ts, null, null, null, null);
+ TmfEvent ev = new EmptyEvent();
try {
eventsQueue.put(ev);
}
}
+ // ------------------------------------------------------------------------
+ // Inner classes
+ // ------------------------------------------------------------------------
+
+ /**
+ * Empty event that should be totally ignored by the event handler. It can
+ * by used for synchronisation purposes.
+ */
+ private class EmptyEvent extends TmfEvent {
+ public EmptyEvent() {
+ super(null, new TmfTimestamp(0), null, null, null, null);
+ }
+ }
+
/**
* This is the runner class for the second thread, which will take the
* events from the queue and pass them through the state system.
try {
event = eventsQueue.take();
while (event.getTimestamp().getValue() != -1) {
+ if (event instanceof EmptyEvent) {
+ /* Synchronization event, should be ignored */
+ event = eventsQueue.take();
+ continue;
+ }
+
currentEvent = event;
/* Make sure this is an event the sub-class can process */