From 35a9a1e83499fd6816f0ebaef8d79148310d1f2d Mon Sep 17 00:00:00 2001 From: Chris Wiebe Date: Fri, 6 Aug 2004 20:47:31 +0000 Subject: [PATCH] Add scheduling rule to CoreModel.run --- core/org.eclipse.cdt.core/ChangeLog | 5 ++ .../org/eclipse/cdt/core/model/CoreModel.java | 77 +++++++++++++++++-- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index f067b00fcd9..02688779a10 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -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. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index 83e96bea28c..a034eae910a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -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. + *

+ * 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. + *

+ *

+ * 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. + *

+ *

+ * If this method is called in the dynamic scope of another such + * call, this method simply runs the action. + *

+ * + * @param action the action to perform + * @param monitor a progress monitor, or null 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. + *

+ * 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. + *

+ *

+ * 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. + *

+ *

+ * If this method is called in the dynamic scope of another such + * call, this method simply runs the action. + *

+ *

+ * The supplied scheduling rule is used to determine whether this operation can be + * run simultaneously with workspace changes in other threads. See + * IWorkspace.run(...) for more details. + *

+ * + * @param action the action to perform + * @param rule the scheduling rule to use when running this operation, or + * null if there are no scheduling restrictions for this operation. + * @param monitor a progress monitor, or null 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(); }