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();
|
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 {
|
||||||
|
err.flush();
|
||||||
|
output.flush();
|
||||||
|
flushed = true;
|
||||||
|
} catch (IOException e1) {
|
||||||
|
}
|
||||||
|
waited = 0;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(DELAY);
|
waited += DELAY;
|
||||||
|
Thread.sleep(DELAY);
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
flushed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,7 +301,8 @@ public class BuildConsolePartitioner
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() throws IOException {
|
public void flush() throws IOException {
|
||||||
appendToDocument(readBuffer(), fStream);
|
if( fBuffer.length() > 0 )
|
||||||
|
appendToDocument(readBuffer(), fStream);
|
||||||
fManager.showConsole();
|
fManager.showConsole();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +312,8 @@ 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);
|
||||||
flush();
|
if( fBuffer.length() > 4096 )
|
||||||
|
flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue