Skip to content

Commit 7f44cf5

Browse files
committed
Revert "SwingConsolePane: first cut at batching the output"
This reverts commit 881065a. Batching the output does not provide great performance gains, and it causes problems with the reliability of output delivery. But we'll leave the work in place in the history: a) so the history documents why things are the way they are; and b) in case anyone wants to make a more nuanced attempt at batching output in the future.
1 parent 881065a commit 7f44cf5

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

src/main/java/org/scijava/ui/swing/console/SwingConsolePane.java

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.awt.Component;
3636
import java.awt.Dimension;
3737
import java.awt.Font;
38-
import java.util.concurrent.ConcurrentLinkedQueue;
3938

4039
import javax.swing.JPanel;
4140
import javax.swing.JScrollPane;
@@ -82,13 +81,6 @@ public class SwingConsolePane extends AbstractConsolePane<JPanel> {
8281
*/
8382
private Component window;
8483

85-
/** Output queue, to avoid excessive queuing to the EDT. */
86-
private ConcurrentLinkedQueue<OutputEvent> outputQueue =
87-
new ConcurrentLinkedQueue<OutputEvent>();
88-
89-
/** Flag indicating that the EDT is currently flushing the output. */
90-
private boolean outputFlushing;
91-
9284
public SwingConsolePane(final Context context) {
9385
super(context);
9486
}
@@ -115,29 +107,19 @@ public JScrollPane getScrollPane() {
115107
@Override
116108
public void append(final OutputEvent event) {
117109
if (consolePanel == null) initConsolePanel();
118-
outputQueue.add(event);
119-
if (outputFlushing) return;
120-
outputFlushing = true;
121-
122110
threadService.queue(new Runnable() {
123111

124112
@Override
125113
public void run() {
126-
while (true) {
127-
outputFlushing = !outputQueue.isEmpty();
128-
final OutputEvent item = outputQueue.poll();
129-
if (item == null) break;
130-
131-
final boolean atBottom =
132-
StaticSwingUtils.isScrolledToBottom(scrollPane);
133-
try {
134-
doc.insertString(doc.getLength(), item.getOutput(), getStyle(item));
135-
}
136-
catch (final BadLocationException exc) {
137-
throw new RuntimeException(exc);
138-
}
139-
if (atBottom) StaticSwingUtils.scrollToBottom(scrollPane);
114+
final boolean atBottom =
115+
StaticSwingUtils.isScrolledToBottom(scrollPane);
116+
try {
117+
doc.insertString(doc.getLength(), event.getOutput(), getStyle(event));
118+
}
119+
catch (final BadLocationException exc) {
120+
throw new RuntimeException(exc);
140121
}
122+
if (atBottom) StaticSwingUtils.scrollToBottom(scrollPane);
141123
}
142124
});
143125
}

0 commit comments

Comments
 (0)