From eafbeb6d4416790e4632913ff60f7faf3c8a54dd Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Thu, 8 Dec 2016 14:10:00 -0500 Subject: [PATCH] Revert "avoid pessimizing audio slave lock contention" This reverts commit 3508e717532e09a8237c8060903843df0e8658e7. --- .../src/audio/AudioMixerSlavePool.cpp | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/assignment-client/src/audio/AudioMixerSlavePool.cpp b/assignment-client/src/audio/AudioMixerSlavePool.cpp index ca6ab7960f..9bc28ec24a 100644 --- a/assignment-client/src/audio/AudioMixerSlavePool.cpp +++ b/assignment-client/src/audio/AudioMixerSlavePool.cpp @@ -27,7 +27,7 @@ void AudioMixerSlaveThread::run() { bool stopping = _stop; notify(stopping); if (stopping) { - break; + return; } } } @@ -80,13 +80,14 @@ void AudioMixerSlavePool::mix(ConstIter begin, ConstIter end, unsigned int frame _queue.emplace(node); }); - // mix - _numStarted = _numFinished = 0; - _slaveCondition.notify_all(); - - // wait { Lock lock(_mutex); + + // mix + _numStarted = _numFinished = 0; + _slaveCondition.notify_all(); + + // wait _poolCondition.wait(lock, [&] { assert(_numFinished <= _numThreads); return _numFinished == _numThreads; @@ -153,12 +154,12 @@ void AudioMixerSlavePool::resize(int numThreads) { } // ...cycle them until they do stop... - _numStopped = 0; - while (_numStopped != (_numThreads - numThreads)) { - _numStarted = _numFinished = _numStopped; - _slaveCondition.notify_all(); - { - Lock lock(_mutex); + { + Lock lock(_mutex); + _numStopped = 0; + while (_numStopped != (_numThreads - numThreads)) { + _numStarted = _numFinished = _numStopped; + _slaveCondition.notify_all(); _poolCondition.wait(lock, [&] { assert(_numFinished <= _numThreads); return _numFinished == _numThreads;