Slow down the consumer waiting loop as to not burn too much CPU.

git-svn-id: http://yate.null.ro/svn/yate/trunk@6064 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2015-11-13 07:47:38 +00:00
parent 8526e7f01f
commit 03752b3f44
1 changed files with 9 additions and 1 deletions

View File

@ -362,11 +362,19 @@ void WaveSource::run()
// internally reference if used for override or replace purpose
bool noChan = (0 == m_chan);
// wait until at least one consumer is attached
unsigned int fast = 4;
while (!r) {
lock();
r = m_consumers.count();
unlock();
Thread::yield();
if (r)
;
else if (fast) {
--fast;
Thread::yield();
}
else
Thread::idle();
if (!looping(noChan)) {
notify(0,"replaced");
return;