diff --git a/Source/Async/AuGroupWorkQueue.cpp b/Source/Async/AuGroupWorkQueue.cpp index 9b8a9977..1c6107a4 100644 --- a/Source/Async/AuGroupWorkQueue.cpp +++ b/Source/Async/AuGroupWorkQueue.cpp @@ -66,20 +66,25 @@ namespace Aurora::Async #endif } - void GroupWorkQueue::Dequeue(AuList &queue, int maxPopCount, AuAsync::ThreadId_t id) + void GroupWorkQueue::Dequeue(AuList &queue, + AuUInt uMaxPopCount, + AuAsync::ThreadId_t id) { AU_LOCK_GUARD(this->mutex); + AuUInt uAnyCount {}; for (AU_ITERATE_N(i, AuAsync::kEWorkPriorityCount)) { auto &group = this->sortedWork[(int)AuAsync::kEWorkPriorityMaxLegal - i]; - for (auto itr = group.begin(); ((itr != group.end()) && (queue.size() < maxPopCount)); ) + for (auto itr = group.begin(); ((itr != group.end()) && (queue.size() < uMaxPopCount)); ) { - if (itr->first == Async::kThreadIdAny) + if ((!uAnyCount) && + (itr->first == Async::kThreadIdAny)) { queue.push_back(*itr); itr = group.erase(itr); + uAnyCount++; continue; } diff --git a/Source/Async/AuGroupWorkQueue.hpp b/Source/Async/AuGroupWorkQueue.hpp index 826217f6..32bfa075 100644 --- a/Source/Async/AuGroupWorkQueue.hpp +++ b/Source/Async/AuGroupWorkQueue.hpp @@ -26,6 +26,6 @@ namespace Aurora::Async void AddWorkEntry(WorkEntry_t entry); - void Dequeue(AuList &queue, int maxPopCount, AuAsync::ThreadId_t idd); + void Dequeue(AuList &queue, AuUInt uMaxPopCount, AuAsync::ThreadId_t idd); }; } \ No newline at end of file diff --git a/Source/Async/ThreadPool.cpp b/Source/Async/ThreadPool.cpp index 3cd9e1e5..392f2c23 100644 --- a/Source/Async/ThreadPool.cpp +++ b/Source/Async/ThreadPool.cpp @@ -308,7 +308,9 @@ namespace Aurora::Async do { - group->workQueue.Dequeue(state->pendingWorkItems, state->stackState.uWorkMultipopCount, state->thread.id.second); + group->workQueue.Dequeue(state->pendingWorkItems, + state->stackState.uWorkMultipopCount, + state->thread.id.second); state->sync.UpdateCVState(state.get()); @@ -394,8 +396,6 @@ namespace Aurora::Async // in the first task (or deeper) if (InRunnerMode() && state->stackState.uStackCallDepth) // are we one call deep? { - auto queue = ToKernelWorkQueue(); - if ((this->uAtomicCounter == state->stackState.uStackCallDepth) && this->IsDepleted()) { @@ -459,8 +459,6 @@ namespace Aurora::Async // in the top most task if (InRunnerMode()) { - auto queue = ToKernelWorkQueue(); - if ((runningTasks == 0) && (this->uAtomicCounter == 0) && this->IsDepleted())