[*] Fix OSThread regression / main thread was stalling for a few seconds on exit because the schedulers end of thread clean up was bailing out under the "pls no dtor race before the os spawn kicks in" lock path
TODO: destink OSThread
This commit is contained in:
parent
16f7d985fc
commit
cdad552ed0
@ -176,10 +176,7 @@ namespace Aurora::Threading::Threads
|
||||
// Kill the current OS thread instance
|
||||
TeminateOSContext(false);
|
||||
|
||||
if (this->exitOnlyOnce_)
|
||||
{
|
||||
this->exitOnlyOnce_->Unlock();
|
||||
}
|
||||
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||
if (this->terminated_)
|
||||
@ -370,10 +367,6 @@ namespace Aurora::Threading::Threads
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this->exitOnlyOnce_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// attempt to join with the thread once it has exited, or timeout
|
||||
if (this->terminated_->LockMS(this->qwExitTimeout))
|
||||
@ -598,6 +591,7 @@ namespace Aurora::Threading::Threads
|
||||
AU_LOCK_GUARD(pFlag->mutex);
|
||||
if (pFlag->bLock)
|
||||
{
|
||||
this->SignalDeath();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -626,25 +620,13 @@ namespace Aurora::Threading::Threads
|
||||
// "Safer" update
|
||||
this->HookOnExit();
|
||||
|
||||
|
||||
if (this->terminated_)
|
||||
{
|
||||
if (this->exitOnlyOnce_)
|
||||
{
|
||||
this->exitOnlyOnce_->Unlock();
|
||||
}
|
||||
this->terminated_->Set();
|
||||
}
|
||||
|
||||
if (this->terminatedSignalLs_)
|
||||
{
|
||||
this->terminatedSignalLs_->Set();
|
||||
}
|
||||
this->SignalDeath();
|
||||
}
|
||||
|
||||
AU_LOCK_GUARD(pFlag->mutex);
|
||||
if (pFlag->bLock)
|
||||
{
|
||||
this->SignalDeath();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1325,11 +1307,6 @@ namespace Aurora::Threading::Threads
|
||||
{
|
||||
if (!locked)
|
||||
{
|
||||
if (!this->exitOnlyOnce_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this->exitOnlyOnce_->TryLock())
|
||||
{
|
||||
return false;
|
||||
@ -1359,36 +1336,30 @@ namespace Aurora::Threading::Threads
|
||||
|
||||
HookReleaseThreadResources();
|
||||
|
||||
if (this->terminatedSignalLs_)
|
||||
{
|
||||
this->terminatedSignalLs_->Set();
|
||||
}
|
||||
|
||||
if (this->terminated_)
|
||||
{
|
||||
this->exitOnlyOnce_->Unlock();
|
||||
this->terminated_->Set(); // must be set last, after which point we cannot use this!
|
||||
}
|
||||
this->SignalDeath();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OSThread::InternalKillForceNtfy()
|
||||
void OSThread::SignalDeath()
|
||||
{
|
||||
if (this->terminated_)
|
||||
{
|
||||
if (this->exitOnlyOnce_)
|
||||
{
|
||||
this->exitOnlyOnce_->Unlock();
|
||||
}
|
||||
this->terminated_->Set();
|
||||
}
|
||||
|
||||
if (this->terminatedSignalLs_)
|
||||
{
|
||||
this->terminatedSignalLs_->Set();
|
||||
}
|
||||
|
||||
if (this->terminated_)
|
||||
{
|
||||
this->exitOnlyOnce_->Unlock();
|
||||
this->terminated_->Set();
|
||||
}
|
||||
}
|
||||
|
||||
bool OSThread::InternalKillForceNtfy()
|
||||
{
|
||||
this->SignalDeath();
|
||||
|
||||
|
||||
// Great C++ ABI guys...
|
||||
#if defined(AURORA_HAS_PTHREADS)
|
||||
{
|
||||
|
@ -53,6 +53,7 @@ namespace Aurora::Threading::Threads
|
||||
AuSPtr<AuLoop::ILoopSource> GetShutdownSignalLS() override;
|
||||
|
||||
bool InternalKillForceNtfy();
|
||||
void SignalDeath();
|
||||
bool InternalKill(bool locked);
|
||||
|
||||
void AffinityPrioThrottleTickAmendECores();
|
||||
|
Loading…
Reference in New Issue
Block a user