tmf: Fix the actual end time of state system modules
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / statesystem / AbstractTmfStateProvider.java
index 46dd6ceff4cd0cfc87973945e06aae871d3bb30c..319f620c0a7a0a3232b86def800081b2885628e4 100644 (file)
@@ -45,10 +45,12 @@ public abstract class AbstractTmfStateProvider implements ITmfStateProvider {
     private final Thread fEventHandlerThread;
 
     private boolean fStateSystemAssigned;
-
     /** State system in which to insert the state changes */
     private @Nullable ITmfStateSystemBuilder fSS = null;
 
+    /* The last safe time at which this state provider can be queried */
+    private volatile long fSafeTime;
+
     /**
      * Instantiate a new state provider plugin.
      *
@@ -61,6 +63,8 @@ public abstract class AbstractTmfStateProvider implements ITmfStateProvider {
         fTrace = trace;
         fEventsQueue = new BufferedBlockingQueue<>(DEFAULT_EVENTS_QUEUE_SIZE, DEFAULT_EVENTS_CHUNK_SIZE);
         fStateSystemAssigned = false;
+        // set the safe time to before the trace start, the analysis has not yet started
+        fSafeTime = trace.getStartTime().toNanos() - 1;
 
         fEventHandlerThread = new Thread(new EventProcessor(), id + " Event Handler"); //$NON-NLS-1$
     }
@@ -84,6 +88,14 @@ public abstract class AbstractTmfStateProvider implements ITmfStateProvider {
         return fTrace.getStartTime().toNanos();
     }
 
+    /**
+     * @since 2.0
+     */
+    @Override
+    public long getLatestSafeTime() {
+        return fSafeTime;
+    }
+
     @Override
     public void assignTargetStateSystem(ITmfStateSystemBuilder ssb) {
         fSS = ssb;
@@ -197,6 +209,7 @@ public abstract class AbstractTmfStateProvider implements ITmfStateProvider {
                     continue;
                 }
                 currentEvent = event;
+                fSafeTime = event.getTimestamp().toNanos() - 1;
                 eventHandle(event);
                 event = fEventsQueue.take();
             }
This page took 0.032018 seconds and 5 git commands to generate.