Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2009-01-28 21:49:50 +0000
committerDarin Wright2009-01-28 21:49:50 +0000
commitbeada81e2caa78650b7cf6f84dfa9333c37af2f5 (patch)
tree6e214ab865b60c0e35e1d7b9607623cd4b71e6cc /org.eclipse.ui.console
parent24daab616fa9b9c44ec227b8d1f538406bbb97de (diff)
downloadeclipse.platform.debug-beada81e2caa78650b7cf6f84dfa9333c37af2f5.tar.gz
eclipse.platform.debug-beada81e2caa78650b7cf6f84dfa9333c37af2f5.tar.xz
eclipse.platform.debug-beada81e2caa78650b7cf6f84dfa9333c37af2f5.zip
Bug 259107 - [console] Console Deadlock when too much information written
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java105
1 files changed, 56 insertions, 49 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
index 142cc7c00..cbc70c71c 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
@@ -467,15 +467,10 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
}
} else {
/*
- * if we are in UI thread we cannot lock it, so spin event
- * loop. The caller will see this as locking but UI will
- * stay responsive.
+ * if we are in UI thread we cannot lock it, so process
+ * queued output.
*/
- while(fBuffer != 0){
- if(!Display.getDefault().readAndDispatch()){
- Display.getDefault().sleep();
- }
- }
+ processQueue();
}
}
}
@@ -516,47 +511,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
* @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public IStatus runInUIThread(IProgressMonitor monitor) {
- synchronized (overflowLock) {
- ArrayList pendingCopy = new ArrayList();
- StringBuffer buffer = null;
- boolean consoleClosed = false;
- while (pendingPartitions.size() > 0) {
- synchronized(pendingPartitions) {
- pendingCopy.addAll(pendingPartitions);
- pendingPartitions.clear();
- fBuffer = 0;
- pendingPartitions.notifyAll();
- }
-
- buffer = new StringBuffer();
- for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) {
- PendingPartition pp = (PendingPartition) i.next();
- if (pp != consoleClosedPartition) {
- buffer.append(pp.text);
- } else {
- consoleClosed = true;
- }
- }
- }
-
- if (connected) {
- setUpdateInProgress(true);
- updatePartitions = pendingCopy;
- firstOffset = document.getLength();
- try {
- document.replace(firstOffset, 0, buffer.toString());
- } catch (BadLocationException e) {
- }
- updatePartitions = null;
- setUpdateInProgress(false);
- }
- if (consoleClosed) {
- console.partitionerFinished();
- }
- checkBufferSize();
-
- }
-
+ processQueue();
return Status.OK_STATUS;
}
@@ -573,6 +528,58 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
}
}
+ void processQueue() {
+ synchronized (overflowLock) {
+ ArrayList pendingCopy = new ArrayList();
+ StringBuffer buffer = null;
+ boolean consoleClosed = false;
+ while (pendingPartitions.size() > 0) {
+ synchronized(pendingPartitions) {
+ pendingCopy.addAll(pendingPartitions);
+ pendingPartitions.clear();
+ fBuffer = 0;
+ pendingPartitions.notifyAll();
+ }
+ // determine buffer size
+ int size = 0;
+ for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) {
+ PendingPartition pp = (PendingPartition) i.next();
+ if (pp != consoleClosedPartition) {
+ size+= pp.text.length();
+ }
+ }
+ buffer = new StringBuffer(size);
+ for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) {
+ PendingPartition pp = (PendingPartition) i.next();
+ if (pp != consoleClosedPartition) {
+ buffer.append(pp.text);
+ } else {
+ consoleClosed = true;
+ }
+ }
+ }
+
+ if (connected) {
+ setUpdateInProgress(true);
+ updatePartitions = pendingCopy;
+ firstOffset = document.getLength();
+ try {
+ if (buffer != null) {
+ document.replace(firstOffset, 0, buffer.toString());
+ }
+ } catch (BadLocationException e) {
+ }
+ updatePartitions = null;
+ setUpdateInProgress(false);
+ }
+ if (consoleClosed) {
+ console.partitionerFinished();
+ }
+ checkBufferSize();
+ }
+
+ }
+
/**
* Job to trim the console document, runs in the UI thread.
*/

Back to the top