Skip to main content
summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorJames Blackburn2010-05-12 05:28:03 -0400
committerJames Blackburn2010-05-12 05:28:03 -0400
commit7b265afa4e7567f64127641f347503cb1cda42fa (patch)
tree237b4fe9c28d881edbfcd3574bd0f3effeba8a38 /build
parent18f0684dd37d349f36d84053c916318243032e76 (diff)
downloadorg.eclipse.cdt-7b265afa4e7567f64127641f347503cb1cda42fa.tar.gz
org.eclipse.cdt-7b265afa4e7567f64127641f347503cb1cda42fa.tar.xz
org.eclipse.cdt-7b265afa4e7567f64127641f347503cb1cda42fa.zip
Bug 312552 Use ILock rather than scheduling rule for mutual exclusion. Scheduling rules require knowing in advance all scheduling rules clients require.
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/CfgDiscoveredPathManager.java56
1 files changed, 14 insertions, 42 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/CfgDiscoveredPathManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/CfgDiscoveredPathManager.java
index cd32ab4447..c4f7d7c958 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/CfgDiscoveredPathManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/CfgDiscoveredPathManager.java
@@ -60,7 +60,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.ILock;
+import org.eclipse.core.runtime.jobs.Job;
public class CfgDiscoveredPathManager implements IResourceChangeListener {
@@ -69,39 +70,9 @@ public class CfgDiscoveredPathManager implements IResourceChangeListener {
private IDiscoveredPathManager fBaseMngr;
+ /** Deadlock-safe mutex lock */
+ private ILock lock = Job.getJobManager().newLock();
- private class GetDiscoveredInfoRunnable implements IWorkspaceRunnable {
-
- private PathInfo fPathInfo;
- private ContextInfo fContextInfo;
- private IProject fProject;
- private CfgInfoContext fContext;
-
- public GetDiscoveredInfoRunnable(ContextInfo cInfo, IProject project, CfgInfoContext context) {
- fContextInfo = cInfo;
- fProject = project;
- fContext = context;
- }
-
- public void run(IProgressMonitor monitor) throws CoreException {
-
- fPathInfo = getCachedPathInfo(fContextInfo);
-
- if(fPathInfo == null){
- IDiscoveredPathManager.IDiscoveredPathInfo baseInfo = loadPathInfo(fProject, fContext.getConfiguration(), fContextInfo);
-
- fPathInfo = resolveCacheBaseDiscoveredInfo(fContextInfo, baseInfo);
- }
-
- }
-
- public PathInfo getPathInfo() {
- return fPathInfo;
- }
-
- };
-
-
private static class ContextInfo {
public ContextInfo() {
@@ -196,16 +167,17 @@ public class CfgDiscoveredPathManager implements IResourceChangeListener {
PathInfo info = getCachedPathInfo(cInfo);
if (info == null) {
- // Change synchronization to be a lock on the project, otherwise
- // if the project description is queried from a project change listener, it will deadlock
-
- GetDiscoveredInfoRunnable runnable = new GetDiscoveredInfoRunnable(cInfo, project, context);
- ISchedulingRule rule = project;
-
- ResourcesPlugin.getWorkspace().run(runnable, rule, IWorkspace.AVOID_UPDATE, null);
-
- info = runnable.getPathInfo();
+ try {
+ lock.acquire();
+ info = getCachedPathInfo(cInfo);
+ if(info == null){
+ IDiscoveredPathManager.IDiscoveredPathInfo baseInfo = loadPathInfo(project, context.getConfiguration(), cInfo);
+ info = resolveCacheBaseDiscoveredInfo(cInfo, baseInfo);
+ }
+ } finally {
+ lock.release();
+ }
}
return info;
}

Back to the top