From 0d3a54a39afe440c6521ffa3caf6cda7aa2a2c9f Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Wed, 5 Feb 2014 17:09:25 -0500 Subject: [PATCH] tmf: Avoid hanging when waiting on a cancelled analysis 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 Reviewed-on: https://git.eclipse.org/r/21590 Tested-by: Hudson CI Reviewed-by: Genevieve Bastien IP-Clean: Genevieve Bastien --- .../tmf/core/analysis/TmfAbstractAnalysisModule.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java index 4e90fe8c91..bfda90f42f 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java @@ -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; } -- 2.34.1