Skip to content

Commit

Permalink
Use QMutexLocker
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Mar 13, 2018
1 parent 4cd7d1b commit 99b747d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/engine/engineworkerscheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,21 @@ void EngineWorkerScheduler::runWorkers() {
void EngineWorkerScheduler::run() {
while (!m_bQuit) {
Event::start("EngineWorkerScheduler");
m_mutex.lock();
for(const auto& pWorker: m_workers) {
if (pWorker->isReady()) {
pWorker->wake();
{
QMutexLocker lock(&m_mutex);
for(const auto& pWorker: m_workers) {
if (pWorker->isReady()) {
pWorker->wake();
}
}
}
m_mutex.unlock();
Event::end("EngineWorkerScheduler");
m_mutex.lock();
if (!m_bQuit) {
// Wait for next runWorkers() call
m_waitCondition.wait(&m_mutex); // unlock mutex and wait
{
QMutexLocker lock(&m_mutex);
if (!m_bQuit) {
// Wait for next runWorkers() call
m_waitCondition.wait(&m_mutex); // unlock mutex and wait
}
}
m_mutex.unlock();
}
}

0 comments on commit 99b747d

Please sign in to comment.