tmf: Avoid hanging when waiting on a cancelled analysis
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 5 Feb 2014 22:09:25 +0000 (17:09 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 6 Feb 2014 15:21:32 +0000 (10:21 -0500)
Also bumped the timeout on await() to 500 ms. It means that, on
average, the user will have to wait 250 ms after clicking on
the cancel button actually cancels the running analysis. 1 ms
was burning CPU cycles for nothing.

Change-Id: Id716c761a60b97d53d6809d0457e4f30b63f655e
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/21590
Tested-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
IP-Clean: Genevieve Bastien <gbastien+lttng@versatic.net>

org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java

index 4e90fe8c91668ea82b5a1320033b5f5b57c7dc08..bfda90f42fdfbbcfe075c4864af858c3097af5eb 100644 (file)
@@ -180,6 +180,7 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
      * Set the countdown latch back to 1 so the analysis can be executed again
      */
     protected void resetAnalysis() {
+        fFinishedLatch.countDown();
         fFinishedLatch = new CountDownLatch(1);
     }
 
@@ -313,8 +314,8 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
     @Override
     public boolean waitForCompletion(IProgressMonitor monitor) {
         try {
-            while (!fFinishedLatch.await(1, TimeUnit.MILLISECONDS)) {
-                if (monitor.isCanceled()) {
+            while (!fFinishedLatch.await(500, TimeUnit.MILLISECONDS)) {
+                if (fAnalysisCancelled || monitor.isCanceled()) {
                     fAnalysisCancelled = true;
                     return false;
                 }
This page took 0.030918 seconds and 5 git commands to generate.