Core/TaskScheduler: Fix deadlock when exiting

If a worker was not given a task, it could happen to ignore the exit signal (for example if it's set before the worker started, causing it to clear the notifier boolean and test it again before checking m_running)
This commit is contained in:
SirLynix
2024-02-04 13:43:55 +01:00
parent 44617bd14d
commit b69c0bb444
2 changed files with 6 additions and 8 deletions

View File

@@ -131,7 +131,7 @@ namespace Nz
std::shuffle(randomWorkerIndices.begin(), randomWorkerIndices.end(), gen);
}
do
while (m_running.load(std::memory_order_relaxed))
{
// Get a task
TaskScheduler::Task* task;
@@ -168,7 +168,6 @@ namespace Nz
m_notifier.clear();
}
}
while (m_running.load(std::memory_order_relaxed));
}
TaskScheduler::Task* StealTask()