[+] Secret AuAsync::KeepThreadPoolAlive api (for now)
This commit is contained in:
parent
dd13098022
commit
e68dc02e7e
@ -586,7 +586,7 @@ namespace Aurora::Async
|
||||
auto queue = ToKernelWorkQueue();
|
||||
|
||||
if ((runningTasks == 0) &&
|
||||
(this->uAtomicCounter == 0 ) &&
|
||||
(this->uAtomicCounter == 0) &&
|
||||
(!queue || queue->GetSourceCount() <= 1 + this->uAtomicIOProcessorsWorthlessSources + this->uAtomicIOProcessors))
|
||||
{
|
||||
Shutdown();
|
||||
@ -1512,4 +1512,32 @@ namespace Aurora::Async
|
||||
StartSched();
|
||||
return AuMakeShared<ThreadPool>();
|
||||
}
|
||||
|
||||
struct KeepGroupAlive
|
||||
{
|
||||
KeepGroupAlive(AuSPtr<AuAsync::IThreadPool> pPool) : pPool(AuStaticCast<AuAsync::ThreadPool>(pPool))
|
||||
{
|
||||
AuAtomicAdd(&this->pPool->uAtomicCounter, 1u);
|
||||
}
|
||||
|
||||
~KeepGroupAlive()
|
||||
{
|
||||
auto uNow = AuAtomicSub(&this->pPool->uAtomicCounter, 1u);
|
||||
|
||||
if (uNow == 0)
|
||||
{
|
||||
for (const auto &[group, pState] : this->pPool->threads_)
|
||||
{
|
||||
pState->BroadCast();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AuSPtr<AuAsync::ThreadPool> pPool;
|
||||
};
|
||||
|
||||
AUKN_SYM AuSPtr<void> KeepThreadPoolAlive(AuSPtr<AuAsync::IThreadPool> pPool)
|
||||
{
|
||||
return AuMakeSharedThrow<KeepGroupAlive>(pPool);
|
||||
}
|
||||
}
|
@ -143,5 +143,7 @@ namespace Aurora::Async
|
||||
AuThreadPrimitives::RWRenterableLock rwlock_;
|
||||
AuThreadPrimitives::Event shutdownEvent_;
|
||||
bool runnersRunning_ {};
|
||||
|
||||
friend struct KeepGroupAlive;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user