aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2018-06-14 03:46:38 -0400
committerAndrey Loskutov2018-06-14 05:15:33 -0400
commit2d9aaed146f02c9f46d082f6cf63a17f11d91210 (patch)
tree1a1f369093ca503009c7c9cd16a6b29f66b2972f
parent04c0b35dc76a6894ba060e486aae3e05d9fa867b (diff)
downloadeclipse.platform.debug-2d9aaed146f02c9f46d082f6cf63a17f11d91210.zip
eclipse.platform.debug-2d9aaed146f02c9f46d082f6cf63a17f11d91210.tar.gz
eclipse.platform.debug-2d9aaed146f02c9f46d082f6cf63a17f11d91210.tar.xz
Queue async tasks coming from ChildrenUpdate's jobs via scheduleViewerUpdate() in the same queue with async tasks coming from modelChanged(), so that they all run in more predictable order. This allows us to run async UI updates triggered by ElementContentProvider jobs before we run next batch of model change events. Additionally this should further reduce the number of Display.asyncExec() tasks coming from debugger. Change-Id: I4a16e9cc79ab453b35d064c85440b726a4772442 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java31
1 files changed, 22 insertions, 9 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java
index e6b5e82..f37bfef 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java
@@ -399,7 +399,7 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
private class DelayedDoModelChangedJob extends WorkbenchJob {
// queue of submitted deltas to process
- private final List<DelayedDoModelChange> fQueue = new ArrayList<>();
+ private final List<Object> fQueue = new ArrayList<>();
private boolean shutdown;
public DelayedDoModelChangedJob() {
@@ -410,7 +410,7 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- List<DelayedDoModelChange> currentBatch = new ArrayList<>();
+ List<Object> currentBatch = new ArrayList<>();
synchronized (fQueue) {
if (shutdown || fQueue.isEmpty()) {
return Status.OK_STATUS;
@@ -421,21 +421,26 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
if (DebugUIPlugin.DEBUG_CONTENT_PROVIDER) {
DebugUIPlugin.trace("Delayed batch size: " + currentBatch.size()); //$NON-NLS-1$
}
- for (Iterator<DelayedDoModelChange> iterator = currentBatch.iterator(); iterator.hasNext();) {
- DelayedDoModelChange change = iterator.next();
+ for (Iterator<?> iterator = currentBatch.iterator(); iterator.hasNext();) {
+ Object task = iterator.next();
if (monitor.isCanceled()) {
restoreQueue(currentBatch);
return Status.CANCEL_STATUS;
}
- if (!change.proxy.isDisposed()) {
- doModelChanged(change.delta, change.proxy);
+ if (task instanceof DelayedDoModelChange) {
+ DelayedDoModelChange change = (DelayedDoModelChange) task;
+ if (!change.proxy.isDisposed()) {
+ doModelChanged(change.delta, change.proxy);
+ }
+ } else {
+ ((Runnable) task).run();
}
iterator.remove();
}
return Status.OK_STATUS;
}
- private void restoreQueue(List<DelayedDoModelChange> currentBatch) {
+ private void restoreQueue(List<Object> currentBatch) {
synchronized (fQueue) {
currentBatch.addAll(fQueue);
fQueue.clear();
@@ -444,11 +449,19 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
}
public void runDelayed(final IModelDelta delta, final IModelProxy proxy) {
+ runDelayed(new DelayedDoModelChange(delta, proxy));
+ }
+
+ public void runDelayed(final Runnable uiTask) {
+ runDelayed((Object) uiTask);
+ }
+
+ private void runDelayed(final Object task) {
synchronized (fQueue) {
if (shutdown) {
return;
}
- fQueue.add(new DelayedDoModelChange(delta, proxy));
+ fQueue.add(task);
if (DebugUIPlugin.DEBUG_CONTENT_PROVIDER) {
DebugUIPlugin.trace("Delayed queue size: " + fQueue.size()); //$NON-NLS-1$
}
@@ -1779,7 +1792,7 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
if (Thread.currentThread() == display.getThread()) {
performUpdates();
} else {
- display.asyncExec(updateJob);
+ fDelayedDoModelChangeJob.runDelayed(updateJob);
}
}
}