Core/TaskScheduler: Fix work ending condition

Use remaining task count instead of idle worker count, this avoids a race condition where a worker signals idle after being tasked with a new job
This commit is contained in:
SirLynix
2024-02-03 22:40:12 +01:00
parent 59e172c2ee
commit e3ad9be759
3 changed files with 34 additions and 31 deletions

View File

@@ -40,11 +40,10 @@ namespace Nz
friend Worker;
Worker& GetWorker(unsigned int workerIndex);
void NotifyWorkerActive();
void NotifyWorkerIdle();
void NotifyTaskCompletion();
std::atomic_bool m_idle;
std::atomic_uint m_idleWorkerCount;
std::atomic_uint m_remainingTasks;
std::size_t m_nextWorkerIndex;
std::vector<Worker> m_workers;
MemoryPool<Task> m_tasks;