Skip to content

Commit

Permalink
Bug 578871 - UndoableOperation2ChangeAdapter use ISchedulableOperation
Browse files Browse the repository at this point in the history
Give the caller of the UndoableOperation2ChangeAdapter.execute a hint
that this operation aquires workspace.root as ISchedulingRule.
It freezed the eclipse UI as long as any other Thread (for example
autobuild) had any lock in the workspace.
With the hint a UI can prevent to freeze while waiting for the rule.

The original call to ResourcesPlugin.getWorkspace().run(runnable, pm);
is equivalent to the call of Workspace.run(IWorkspaceRunnable,
IProgressMonitor), which is implemented internally as
run((ICoreRunnable) action, defaultRoot, IWorkspace.AVOID_UPDATE,
monitor); - means, changing the original code to proposed one is safe
and doesn't change any behavior because the executed code it is
identical at the end. It only gives a hint
about the lock that is used anyway.

Workspace.run(IWorkspaceRunnable, IProgressMonitor) was inlined to
give a uniform pattern where the lock is aquired.
  • Loading branch information
EcljpseB0T authored and iloveeclipse committed May 2, 2022
1 parent 8eb048c commit 72c4c91
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions org.eclipse.ltk.core.refactoring/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.ltk.core.refactoring
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ltk.core.refactoring; singleton:=true
Bundle-Version: 3.12.100.qualifier
Bundle-Version: 3.12.200.qualifier
Bundle-Activator: org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand All @@ -17,7 +17,7 @@ Export-Package: org.eclipse.ltk.core.refactoring,
org.eclipse.ltk.internal.core.refactoring.history;x-friends:="org.eclipse.ltk.ui.refactoring,org.eclipse.ltk.core.refactoring.tests",
org.eclipse.ltk.internal.core.refactoring.resource;x-friends:="org.eclipse.ltk.ui.refactoring,org.eclipse.ltk.core.refactoring.tests",
org.eclipse.ltk.internal.core.refactoring.resource.undostates;x-internal:=true
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.25.0,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.4.100,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)",
org.eclipse.core.filebuffers;bundle-version="[3.5.0,4.0.0)",
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.ltk.core.refactoring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
</parent>
<groupId>org.eclipse.ltk</groupId>
<artifactId>org.eclipse.ltk.core.refactoring</artifactId>
<version>3.12.100-SNAPSHOT</version>
<version>3.12.200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulableOperation;
import org.eclipse.core.runtime.jobs.ISchedulingRule;

import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;

Expand All @@ -40,7 +43,7 @@
import org.eclipse.ltk.core.refactoring.RefactoringStatus;


public class UndoableOperation2ChangeAdapter implements IUndoableOperation, IAdvancedUndoableOperation {
public class UndoableOperation2ChangeAdapter implements IUndoableOperation, IAdvancedUndoableOperation, ISchedulableOperation {

private String fLabel;
private String fDescription;
Expand Down Expand Up @@ -348,7 +351,7 @@ private ExecuteResult executeChange(final IValidationCheckResultQuery query, IPr
monitor.done();
}
};
ResourcesPlugin.getWorkspace().run(runnable, pm);
ResourcesPlugin.getWorkspace().run(runnable, getSchedulingRule(), IWorkspace.AVOID_UPDATE, pm);
return result;
}

Expand Down Expand Up @@ -390,4 +393,9 @@ private void clearActiveChange() {
fActiveChange.dispose();
fActiveChange= null;
}

@Override
public ISchedulingRule getSchedulingRule() {
return ResourcesPlugin.getWorkspace().getRoot();
}
}

0 comments on commit 72c4c91

Please sign in to comment.