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:
parent
eadef182c2
commit
66737b8c43
2 changed files with 23 additions and 5 deletions
|
@ -154,27 +154,40 @@ public class CommandLauncher {
|
|||
closure.runNonBlocking();
|
||||
byte buffer[] = new byte[1024];
|
||||
int nbytes;
|
||||
int waited = 0;
|
||||
boolean flushed = false;
|
||||
while (!monitor.isCanceled() && closure.isAlive()) {
|
||||
nbytes = 0;
|
||||
try {
|
||||
if ( errInPipe.available() > 0 ) {
|
||||
nbytes = errInPipe.read(buffer);
|
||||
err.write(buffer, 0, nbytes);
|
||||
err.flush();
|
||||
}
|
||||
if ( inputPipe.available() > 0 ) {
|
||||
nbytes = inputPipe.read(buffer);
|
||||
output.write(buffer, 0, nbytes);
|
||||
output.flush();
|
||||
}
|
||||
} catch( IOException e) {
|
||||
}
|
||||
monitor.worked(0);
|
||||
if (nbytes == 0) {
|
||||
//DELAY * 10 is half a second with no new input, flush anything thats waiting
|
||||
if( !flushed && waited > DELAY * 10 ){
|
||||
try {
|
||||
err.flush();
|
||||
output.flush();
|
||||
flushed = true;
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
waited = 0;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(DELAY);
|
||||
waited += DELAY;
|
||||
Thread.sleep(DELAY);
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
} else {
|
||||
flushed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,9 @@ public class BuildConsolePartitioner
|
|||
*/
|
||||
|
||||
public void appendToDocument(final String text, final BuildConsoleStream stream) {
|
||||
if( text.length() == 0 )
|
||||
return;
|
||||
|
||||
Runnable r = new Runnable() {
|
||||
|
||||
public void run() {
|
||||
|
@ -298,7 +301,8 @@ public class BuildConsolePartitioner
|
|||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
appendToDocument(readBuffer(), fStream);
|
||||
if( fBuffer.length() > 0 )
|
||||
appendToDocument(readBuffer(), fStream);
|
||||
fManager.showConsole();
|
||||
}
|
||||
|
||||
|
@ -308,7 +312,8 @@ public class BuildConsolePartitioner
|
|||
|
||||
public synchronized void write(byte[] b, int off, int len) throws IOException {
|
||||
super.write(b, off, len);
|
||||
flush();
|
||||
if( fBuffer.length() > 4096 )
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue