1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

bug 67718 : have a little more restraint about how often we flush the pipes

This commit is contained in:
Andrew Niefer 2004-07-05 15:34:22 +00:00
parent eadef182c2
commit 66737b8c43
2 changed files with 23 additions and 5 deletions

View file

@ -154,27 +154,40 @@ public class CommandLauncher {
closure.runNonBlocking(); closure.runNonBlocking();
byte buffer[] = new byte[1024]; byte buffer[] = new byte[1024];
int nbytes; int nbytes;
int waited = 0;
boolean flushed = false;
while (!monitor.isCanceled() && closure.isAlive()) { while (!monitor.isCanceled() && closure.isAlive()) {
nbytes = 0; nbytes = 0;
try { try {
if ( errInPipe.available() > 0 ) { if ( errInPipe.available() > 0 ) {
nbytes = errInPipe.read(buffer); nbytes = errInPipe.read(buffer);
err.write(buffer, 0, nbytes); err.write(buffer, 0, nbytes);
err.flush();
} }
if ( inputPipe.available() > 0 ) { if ( inputPipe.available() > 0 ) {
nbytes = inputPipe.read(buffer); nbytes = inputPipe.read(buffer);
output.write(buffer, 0, nbytes); output.write(buffer, 0, nbytes);
output.flush();
} }
} catch( IOException e) { } catch( IOException e) {
} }
monitor.worked(0); monitor.worked(0);
if (nbytes == 0) { if (nbytes == 0) {
//DELAY * 10 is half a second with no new input, flush anything thats waiting
if( !flushed && waited > DELAY * 10 ){
try { try {
err.flush();
output.flush();
flushed = true;
} catch (IOException e1) {
}
waited = 0;
}
try {
waited += DELAY;
Thread.sleep(DELAY); Thread.sleep(DELAY);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
} }
} else {
flushed = false;
} }
} }

View file

@ -72,6 +72,9 @@ public class BuildConsolePartitioner
*/ */
public void appendToDocument(final String text, final BuildConsoleStream stream) { public void appendToDocument(final String text, final BuildConsoleStream stream) {
if( text.length() == 0 )
return;
Runnable r = new Runnable() { Runnable r = new Runnable() {
public void run() { public void run() {
@ -298,6 +301,7 @@ public class BuildConsolePartitioner
} }
public void flush() throws IOException { public void flush() throws IOException {
if( fBuffer.length() > 0 )
appendToDocument(readBuffer(), fStream); appendToDocument(readBuffer(), fStream);
fManager.showConsole(); fManager.showConsole();
} }
@ -308,6 +312,7 @@ public class BuildConsolePartitioner
public synchronized void write(byte[] b, int off, int len) throws IOException { public synchronized void write(byte[] b, int off, int len) throws IOException {
super.write(b, off, len); super.write(b, off, len);
if( fBuffer.length() > 4096 )
flush(); flush();
} }
} }