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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user