tmf.core: Make getParamater synchronized
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.graph.core / src / org / eclipse / tracecompass / analysis / graph / core / criticalpath / CriticalPathModule.java
index 6064f3b345158bc1e5846e97db3fe3fd34f34e48..b0cf581630ed1144b3349d30238eba7a9b1be2da 100644 (file)
@@ -24,9 +24,7 @@ import org.eclipse.tracecompass.internal.analysis.graph.core.criticalpath.Messag
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
 
 /**
@@ -50,7 +48,7 @@ public class CriticalPathModule extends TmfAbstractAnalysisModule {
 
     private @Nullable TmfGraphBuilderModule fGraphModule;
 
-    private @Nullable TmfGraph fCriticalPath;
+    private volatile @Nullable TmfGraph fCriticalPath;
 
     /**
      * Default constructor
@@ -85,7 +83,7 @@ public class CriticalPathModule extends TmfAbstractAnalysisModule {
             return false;
         }
         if (!(workerObj instanceof IGraphWorker)) {
-            throw new IllegalStateException();
+            throw new IllegalStateException("Worker parameter must be an IGraphWorker"); //$NON-NLS-1$
         }
         IGraphWorker worker = (IGraphWorker) workerObj;
 
@@ -95,19 +93,10 @@ public class CriticalPathModule extends TmfAbstractAnalysisModule {
             fCriticalPath = new TmfGraph();
             return true;
         }
-        TmfTimeRange tr = TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange();
-        TmfVertex start = graph.getVertexAt(tr.getStartTime(), worker);
-        if (start == null) {
-            /*
-             * Nothing happens with this worker after start, return an empty
-             * graph
-             */
-            fCriticalPath = new TmfGraph();
-            return true;
-        }
+
         ICriticalPathAlgorithm cp = getAlgorithm(graph);
         try {
-            fCriticalPath = cp.compute(start, null);
+            fCriticalPath = cp.compute(head, null);
             return true;
         } catch (CriticalPathAlgorithmException e) {
             Activator.getInstance().logError(NonNullUtils.nullToEmptyString(e.getMessage()), e);
@@ -121,7 +110,7 @@ public class CriticalPathModule extends TmfAbstractAnalysisModule {
     }
 
     @Override
-    public @Nullable Object getParameter(String name) {
+    public @Nullable synchronized Object getParameter(String name) {
         if (name.equals(PARAM_GRAPH)) {
             return getGraph();
         }
@@ -138,6 +127,7 @@ public class CriticalPathModule extends TmfAbstractAnalysisModule {
 
     @Override
     protected void parameterChanged(String name) {
+        fCriticalPath = null;
         cancel();
         resetAnalysis();
         schedule();
This page took 0.02728 seconds and 5 git commands to generate.