mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Add scheduling rule to CoreModel.run
This commit is contained in:
parent
957c5e4336
commit
35a9a1e834
2 changed files with 77 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
|||
2004-08-06 Chris Wiebe
|
||||
|
||||
Add scheduling rule to CoreModel.run
|
||||
* src/org/eclipse/cdt/core/model/CoreModel.java
|
||||
|
||||
2004-07-30 Alain Magloire
|
||||
|
||||
Add the Using-{directive,declaration} part of the Core Model.
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
|
||||
public class CoreModel {
|
||||
private static CoreModel cmodel = null;
|
||||
|
@ -850,17 +851,83 @@ public class CoreModel {
|
|||
private CoreModel() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs the given action as an atomic C model operation.
|
||||
* <p>
|
||||
* After running a method that modifies C elements,
|
||||
* registered listeners receive after-the-fact notification of
|
||||
* what just transpired, in the form of a element changed event.
|
||||
* This method allows clients to call a number of
|
||||
* methods that modify C elements and only have element
|
||||
* changed event notifications reported at the end of the entire
|
||||
* batch.
|
||||
* </p>
|
||||
* <p>
|
||||
* If this method is called outside the dynamic scope of another such
|
||||
* call, this method runs the action and then reports a single
|
||||
* element changed event describing the net effect of all changes
|
||||
* done to C elements by the action.
|
||||
* </p>
|
||||
* <p>
|
||||
* If this method is called in the dynamic scope of another such
|
||||
* call, this method simply runs the action.
|
||||
* </p>
|
||||
*
|
||||
* @param action the action to perform
|
||||
* @param monitor a progress monitor, or <code>null</code> if progress
|
||||
* reporting and cancellation are not desired
|
||||
* @exception CoreException if the operation failed.
|
||||
* @since 2.1
|
||||
*/
|
||||
public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException {
|
||||
run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
|
||||
}
|
||||
/**
|
||||
* Runs the given action as an atomic C model operation.
|
||||
* <p>
|
||||
* After running a method that modifies C elements,
|
||||
* registered listeners receive after-the-fact notification of
|
||||
* what just transpired, in the form of a element changed event.
|
||||
* This method allows clients to call a number of
|
||||
* methods that modify C elements and only have element
|
||||
* changed event notifications reported at the end of the entire
|
||||
* batch.
|
||||
* </p>
|
||||
* <p>
|
||||
* If this method is called outside the dynamic scope of another such
|
||||
* call, this method runs the action and then reports a single
|
||||
* element changed event describing the net effect of all changes
|
||||
* done to C elements by the action.
|
||||
* </p>
|
||||
* <p>
|
||||
* If this method is called in the dynamic scope of another such
|
||||
* call, this method simply runs the action.
|
||||
* </p>
|
||||
* <p>
|
||||
* The supplied scheduling rule is used to determine whether this operation can be
|
||||
* run simultaneously with workspace changes in other threads. See
|
||||
* <code>IWorkspace.run(...)</code> for more details.
|
||||
* </p>
|
||||
*
|
||||
* @param action the action to perform
|
||||
* @param rule the scheduling rule to use when running this operation, or
|
||||
* <code>null</code> if there are no scheduling restrictions for this operation.
|
||||
* @param monitor a progress monitor, or <code>null</code> if progress
|
||||
* reporting and cancellation are not desired
|
||||
* @exception CoreException if the operation failed.
|
||||
* @since 3.0
|
||||
*/
|
||||
public static void run(IWorkspaceRunnable action, ISchedulingRule rule, IProgressMonitor monitor) throws CoreException {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
if (workspace.isTreeLocked()) {
|
||||
new BatchOperation(action).run(monitor);
|
||||
} else {
|
||||
// use IWorkspace.run(...) to ensure that a build will be done in
|
||||
// autobuild mode
|
||||
workspace.run(new BatchOperation(action), monitor);
|
||||
// use IWorkspace.run(...) to ensure that a build will be done in autobuild mode
|
||||
workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE, monitor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void startIndexing() {
|
||||
manager.getIndexManager().reset();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue