From 2e3c8a351bad6a3ad10a7609ab67ebe85d87c48d Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 15 Jan 2018 12:02:20 +0000 Subject: [PATCH] Added a sleep to ChildProcess::waitForProcessToFinish() to avoid it wasting CPU --- modules/juce_core/threads/juce_ChildProcess.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/juce_core/threads/juce_ChildProcess.cpp b/modules/juce_core/threads/juce_ChildProcess.cpp index 0a74d7bf50..2c14b05ac0 100644 --- a/modules/juce_core/threads/juce_ChildProcess.cpp +++ b/modules/juce_core/threads/juce_ChildProcess.cpp @@ -54,6 +54,8 @@ bool ChildProcess::waitForProcessToFinish (const int timeoutMs) const { if (! isRunning()) return true; + + Thread::sleep (2); } while (timeoutMs < 0 || Time::getMillisecondCounter() < timeoutTime); @@ -66,8 +68,8 @@ String ChildProcess::readAllProcessOutput() for (;;) { - char buffer [512]; - const int num = readProcessOutput (buffer, sizeof (buffer)); + char buffer[512]; + auto num = readProcessOutput (buffer, sizeof (buffer)); if (num <= 0) break;