@@ -263,6 +263,8 @@ void TaskList::AddToThreadQueueExt( Task& task ) {
263263 if ( task.threadMask ) {
264264 uint32 threadMask = task.threadMask ;
265265
266+ taskCount.fetch_add ( CountBits ( threadMask ), std::memory_order_relaxed);
267+
266268 while ( threadMask ) {
267269 const uint32 threadID = FindLSB ( threadMask );
268270 threadQueues[threadID].AddTask ( threadID, task.bufferID );
@@ -273,6 +275,8 @@ void TaskList::AddToThreadQueueExt( Task& task ) {
273275 return ;
274276 }
275277
278+ taskCount.fetch_add ( 1 , std::memory_order_relaxed );
279+
276280 const uint32 projectedTime = taskTime.time / std::max ( taskTime.count , 1ull ) / 1000 ;
277281
278282 if ( projectedTime < TLM.addToQueueTimer .Time () / TLM.addToQueueCount && !TLM.main ) {
@@ -388,8 +392,6 @@ void TaskList::AddTask( Task& task, TaskInitList<T>&& dependencies ) {
388392 AddToThreadQueue ( *taskMemory );
389393 }
390394
391- taskCount.fetch_add ( 1 , std::memory_order_relaxed );
392-
393395 TLM.addTimer .Stop ();
394396}
395397
@@ -494,10 +496,17 @@ Task* TaskList::FetchTask( Thread* thread, const bool longestTask ) {
494496 threadQueue.tasks [current] = ThreadQueue::TASK_NONE;
495497 threadQueue.current = ( current + 1 ) % ThreadQueue::MAX_TASKS;
496498
499+ return &tasks[id];
500+ }
501+
502+ void TaskList::TasksCleared ( const uint32 count ) {
503+ taskCount.fetch_sub ( count, std::memory_order_relaxed );
504+ }
505+
506+ void TaskList::TaskStarted () {
497507 executingThreads.fetch_add ( 1 , std::memory_order_relaxed );
498- taskCount.fetch_sub ( 1 , std::memory_order_relaxed );
499508
500- return &tasks[id] ;
509+ taskCount. fetch_sub ( 1 , std::memory_order_relaxed ) ;
501510}
502511
503512bool TaskList::ThreadFinished ( const bool hadTask ) {
@@ -506,6 +515,7 @@ bool TaskList::ThreadFinished( const bool hadTask ) {
506515
507516 if ( exit ) {
508517 TLM.exitTimer .Start ();
518+ eventQueue.Shutdown ();
509519 }
510520
511521 if ( exit && !threadCount ) {
0 commit comments