зеркало из https://github.com/mozilla/pjs.git
Bug 764147 - SUT agent: reduce CPU usage while waiting for launched process. r=jmaher
This commit is contained in:
Родитель
9d8dfe4e7b
Коммит
ac2d6b40ef
|
@ -17,6 +17,7 @@ public class FindProcThread extends Thread {
|
|||
boolean bStillRunning = true;
|
||||
|
||||
public FindProcThread(ContextWrapper ctx, String sProcessName) {
|
||||
super("FindProcThread");
|
||||
this.contextWrapper = ctx;
|
||||
this.sProcNameToFind = sProcessName;
|
||||
this.bFoundIt = false;
|
||||
|
|
|
@ -20,6 +20,7 @@ public class RedirOutputThread extends Thread
|
|||
|
||||
public RedirOutputThread(Process pProc, OutputStream out)
|
||||
{
|
||||
super("RedirOutputThread");
|
||||
if (pProc != null)
|
||||
{
|
||||
this.pProc = pProc;
|
||||
|
@ -50,6 +51,13 @@ public class RedirOutputThread extends Thread
|
|||
{
|
||||
try
|
||||
{
|
||||
// If there's no output to collect, sleep for a while
|
||||
// rather than checking again immediately, to avoid
|
||||
// using up cpu capacity in a tight loop.
|
||||
if (sutOut.available() == 0 && sutErr.available() == 0)
|
||||
{
|
||||
Thread.sleep(50);
|
||||
}
|
||||
if ((nBytesOut = sutOut.available()) > 0)
|
||||
{
|
||||
if (nBytesOut > buffer.length)
|
||||
|
@ -109,6 +117,10 @@ public class RedirOutputThread extends Thread
|
|||
// Bug 743766: InputStream.available() unexpectedly throws this sometimes
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
pProc.destroy();
|
||||
|
|
Загрузка…
Ссылка в новой задаче