diff --git a/Source/Async/ThreadPool.cpp b/Source/Async/ThreadPool.cpp index 44a21107..02d8816f 100644 --- a/Source/Async/ThreadPool.cpp +++ b/Source/Async/ThreadPool.cpp @@ -1037,9 +1037,23 @@ namespace Aurora::Async void ThreadPool::IncrementAbortFenceOnWorker(WorkerId_t workerId) { - if (auto pState = this->GetThreadHandle(workerId)) + auto group = GetGroup(workerId.first); + + if (workerId.second == kThreadIdAny) { - AuAtomicAdd(&pState->shutdown.uShutdownFence, 1u); + AU_LOCK_GUARD(group->workersMutex); + + for (auto &[jobWorker, pState]: group->workers) + { + AuAtomicAdd(&pState->shutdown.uShutdownFence, 1u); + } + } + else + { + if (auto pState = this->GetThreadHandle(workerId)) + { + AuAtomicAdd(&pState->shutdown.uShutdownFence, 1u); + } } } @@ -1085,7 +1099,7 @@ namespace Aurora::Async bool ThreadPool::Spawn(WorkerId_t workerId, bool create) { - AU_LOCK_GUARD(rwlock_->AsWritable()); + AU_LOCK_GUARD(this->rwlock_->AsWritable()); if (create) {