Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Recoskie2009-12-01 20:29:07 +0000
committerChris Recoskie2009-12-01 20:29:07 +0000
commitb6d0b06f02c0499df384fc0c040ae1c49259f56f (patch)
tree1cd1e47b8cd8ce73d671cc23110930624f7d6908
parent9605f8c40bd8758c287dc1affeb1bab6e0563bff (diff)
downloadorg.eclipse.cdt-b6d0b06f02c0499df384fc0c040ae1c49259f56f.tar.gz
org.eclipse.cdt-b6d0b06f02c0499df384fc0c040ae1c49259f56f.tar.xz
org.eclipse.cdt-b6d0b06f02c0499df384fc0c040ae1c49259f56f.zip
another fix for Bug 295117 - deadlock in CfgDiscoveredPathManager.getDiscoveredInfo()v200912011540
Change PartListenerGroup to use an ILock
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java25
1 files changed, 12 insertions, 13 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java
index 4c45c782719..67ea8817fa8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ILock;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.text.ISelectionValidator;
@@ -55,15 +56,6 @@ public class SelectionListenerWithASTManager {
return fgDefault;
}
- private static class SingletonRule implements ISchedulingRule {
- public boolean contains(ISchedulingRule rule) {
- return rule == this;
- }
- public boolean isConflicting(ISchedulingRule rule) {
- return rule == this;
- }
- }
-
private final static class PartListenerGroup {
private ITextEditor fPart;
private ISelectionListener fPostSelectionListener;
@@ -71,7 +63,7 @@ public class SelectionListenerWithASTManager {
private Job fCurrentJob;
private ListenerList fAstListeners;
/** Rule to make sure only one job is running at a time */
- private final ISchedulingRule fJobRule= new SingletonRule();
+ private final ILock fJobLock= Job.getJobManager().newLock();
private ISelectionValidator fValidator;
public PartListenerGroup(ITextEditor editorPart) {
@@ -144,15 +136,22 @@ public class SelectionListenerWithASTManager {
fCurrentJob= new Job(Messages.SelectionListenerWithASTManager_jobName) {
@Override
public IStatus run(IProgressMonitor monitor) {
- if (!monitor.isCanceled() && isSelectionValid(selection)) {
- return calculateASTandInform(workingCopy, selection, monitor);
+ try {
+ // Try to acquire the lock
+ while (!monitor.isCanceled() && !fJobLock.acquire(10)) {}
+ if (!monitor.isCanceled() && isSelectionValid(selection)) {
+ return calculateASTandInform(workingCopy, selection, monitor);
+ }
+ } catch (InterruptedException e) {
+ } finally {
+ if (fJobLock.getDepth() != 0)
+ fJobLock.release();
}
return Status.OK_STATUS;
}
};
fCurrentJob.setPriority(Job.DECORATE);
fCurrentJob.setSystem(true);
- fCurrentJob.setRule(fJobRule);
fCurrentJob.schedule();
}

Back to the top