aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Montplaisir2013-06-26 14:17:30 -0400
committerAlexandre Montplaisir2013-06-27 16:13:29 -0400
commitade649c3f4715546e48120ad2a965f6d24c0c5c8 (patch)
tree2ae9978a65d70a18455e74719ee2a51080e5c0af
parent5d2b64c8a3de3ee58f363cd51db26c739b8f455a (diff)
downloadorg.eclipse.linuxtools-ade649c3f4715546e48120ad2a965f6d24c0c5c8.tar.gz
org.eclipse.linuxtools-ade649c3f4715546e48120ad2a965f6d24c0c5c8.tar.xz
org.eclipse.linuxtools-ade649c3f4715546e48120ad2a965f6d24c0c5c8.zip
tmf: Fix fake event problem in AbstractTmfStateProvider
For a given state provider, if the last event modifies the state AND the user calls .waitForEmptyQueue() right before closing the tree manually, the resulting history would have an incorrect end time and it would be impossible to query at the timestamp of the last event. This was due do a "fake" synchronization event being set as the provider's current event, so when closing the history it would use its time stamp which is effectively 0. Remedy this by using an internal event class explicitely for this. Thanks to J.-C. Kouamé for finding this one! Change-Id: I06227ca656a67991966b1d1dd15330cb97754fbe Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Reviewed-on: https://git.eclipse.org/r/14080 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AbstractTmfStateProvider.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AbstractTmfStateProvider.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AbstractTmfStateProvider.java
index 95214e1d73..78e5e8cef6 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AbstractTmfStateProvider.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AbstractTmfStateProvider.java
@@ -141,8 +141,7 @@ public abstract class AbstractTmfStateProvider implements ITmfStateProvider {
* 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);
@@ -154,6 +153,20 @@ public abstract class AbstractTmfStateProvider implements ITmfStateProvider {
}
}
+ // ------------------------------------------------------------------------
+ // 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.
@@ -171,6 +184,12 @@ public abstract class AbstractTmfStateProvider implements ITmfStateProvider {
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 */