aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2012-02-01 11:49:32 (EST)
committerOleg Besedin2012-02-01 11:49:32 (EST)
commit1634731aa1325e5c90be3be2b08384414b77f77e (patch)
tree4d4ba005886dd99f0faf1628630cc2d96a0ae670
parent4a32b385308e0465753bdebc7235b5a1aec594e1 (diff)
downloadeclipse.platform.runtime-1634731aa1325e5c90be3be2b08384414b77f77e.zip
eclipse.platform.runtime-1634731aa1325e5c90be3be2b08384414b77f77e.tar.gz
eclipse.platform.runtime-1634731aa1325e5c90be3be2b08384414b77f77e.tar.bz2
recording
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/RunAndTrack.java38
1 files changed, 12 insertions, 26 deletions
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/RunAndTrack.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/RunAndTrack.java
index 3022a34..ac87164 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/RunAndTrack.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/RunAndTrack.java
@@ -21,8 +21,6 @@ import org.eclipse.e4.core.internal.contexts.EclipseContext;
*/
abstract public class RunAndTrack {
- private boolean isRecordingPaused = false;
-
/**
* Creates a new instance of trackable computation
*/
@@ -43,31 +41,19 @@ abstract public class RunAndTrack {
abstract public boolean changed(IEclipseContext context);
/**
- * This method can be called to pause dependency recording while {@link #changed(IEclipseContext)}
- * does its processing. This can be especially useful if external code
- * has to be called. The method {@link #resumeRecoding()} must be called before RunAndTrack
- * returns control to its caller.
- */
- synchronized protected void pauseRecording() {
- if (isRecordingPaused)
- return;
- Stack<Computation> current = EclipseContext.getCalculatedComputations();
- current.push(null);
- isRecordingPaused = true;
- }
-
- /**
- * Call this method to resume dependency recording previously paused by
- * the {@link #pauseRecording()}.
+ * Use this method to wrap calls to external code. For instance, while in {@link #changed(IEclipseContext)}.
+ * consider calling listeners from this method. This wrapper will pause dependency recording while
+ * in the 3rd party code, reducing potential dependency circularity issues.
+ * @param runnable
*/
- synchronized protected void resumeRecoding() {
- if (!isRecordingPaused)
- return;
- Stack<Computation> current = EclipseContext.getCalculatedComputations();
- Computation plug = current.pop();
- if (plug != null)
- throw new IllegalArgumentException("Internal error in nested computation processing"); //$NON-NLS-1$
- isRecordingPaused = false;
+ synchronized protected void runExternalCode(Runnable runnable) {
+ Stack<Computation> computationStack = EclipseContext.getCalculatedComputations();
+ computationStack.push(null);
+ try {
+ runnable.run();
+ } finally {
+ computationStack.pop();
+ }
}
}