From 7ce79da39e2f3284f074b6d128247f8b854a6988 Mon Sep 17 00:00:00 2001 From: Uwe Stieber Date: Sat, 25 May 2013 11:13:22 +0200 Subject: Target Explorer: Improve job state handling for scanner job --- .../src/org/eclipse/tcf/te/tcf/locator/Scanner.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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$ -- cgit v1.2.3