mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 06:24:20 +02:00
algorithm->nestedEach in LimitedNodeList
This commit is contained in:
parent
28960681d9
commit
b2f995d3df
2 changed files with 4 additions and 7 deletions
|
@ -391,10 +391,7 @@ void AudioMixer::start() {
|
|||
|
||||
auto timer = _frameTiming.timer();
|
||||
|
||||
// aquire the read-lock in a single thread, to avoid canonical rwlock undefined behaviors
|
||||
// node removal will acquire a write lock;
|
||||
// read locks (in slave threads) while a write lock is pending have undefined order in pthread
|
||||
nodeList->algorithm([&](NodeList::const_iterator cbegin, NodeList::const_iterator cend) {
|
||||
nodeList->nestedEach([&](NodeList::const_iterator cbegin, NodeList::const_iterator cend) {
|
||||
// prepare frames; pop off any new audio from their streams
|
||||
{
|
||||
auto timer = _prepareTiming.timer();
|
||||
|
|
|
@ -175,15 +175,15 @@ public:
|
|||
|
||||
SharedNodePointer findNodeWithAddr(const HifiSockAddr& addr);
|
||||
|
||||
// for use with algorithm
|
||||
using value_type = SharedNodePointer;
|
||||
using const_iterator = std::vector<value_type>::const_iterator;
|
||||
|
||||
// Cede control of iteration under a single read lock (e.g. for use by thread pools)
|
||||
// Use this for nested loops instead of taking nested read locks!
|
||||
// This allows multiple threads (i.e. a thread pool) to share a lock
|
||||
// without deadlocking when a dying node attempts to acquire a write lock
|
||||
template<typename NodeAlgorithmLambda>
|
||||
void algorithm(NodeAlgorithmLambda functor) {
|
||||
template<typename NestedNodeLambda>
|
||||
void nestedEach(NestedNodeLambda functor) {
|
||||
QReadLocker readLock(&_nodeMutex);
|
||||
|
||||
std::vector<SharedNodePointer> nodes(_nodeHash.size());
|
||||
|
|
Loading…
Reference in a new issue