Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-05-25 09:13:22 +0000
committerUwe Stieber2013-05-25 09:13:22 +0000
commit7ce79da39e2f3284f074b6d128247f8b854a6988 (patch)
treef9215c64e05363d620422ed4fa4ccf1ab3199b90
parent38eb4edaba68356f992c565beea9f99c42a5681a (diff)
downloadorg.eclipse.tcf-7ce79da39e2f3284f074b6d128247f8b854a6988.tar.gz
org.eclipse.tcf-7ce79da39e2f3284f074b6d128247f8b854a6988.tar.xz
org.eclipse.tcf-7ce79da39e2f3284f074b6d128247f8b854a6988.zip
Target Explorer: Improve job state handling for scanner job
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java
index e56e05a01..ff44e7094 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java
@@ -119,7 +119,7 @@ public class Scanner extends Job implements IScanner {
// Terminate the job as soon all scanner runnable's are process
// and reschedule the job (if not terminated)
final IStatus result = finMonitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
- Scanner.this.done(result);
+ if (getState() != Job.NONE) Scanner.this.done(result);
if (!isTerminated()) {
Long delay = (Long)getConfiguration().get(IScanner.PROP_SCHEDULE);
@@ -218,7 +218,16 @@ public class Scanner extends Job implements IScanner {
*/
@Override
public void terminate() {
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ // Return immediately if the scanner has been terminated already
+ if (terminated.get()) return;
+
+ // Mark the scanner job as terminated. This flag is checked by
+ // the asynchronous callbacks and will stop the processing
terminated.set(true);
+ // Mark the job done from the job manager POV
+ if (getState() != Job.NONE) done(Status.CANCEL_STATUS);
if (CoreBundleActivator.getTraceHandler().isSlotEnabled(ITracing.ID_TRACE_SCANNER)) {
CoreBundleActivator.getTraceHandler().trace("Scanner terminated.", ITracing.ID_TRACE_SCANNER, Scanner.this); //$NON-NLS-1$

Back to the top