[*] Harden detached spawn

This commit is contained in:
Reece Wilson 2024-03-02 23:44:59 +00:00
parent 3004c3de19
commit 9591fc9d30

View File

@ -309,6 +309,8 @@ namespace Aurora::Threading::Threads
bool OSThread::Run()
{
AU_DEBUG_MEMCRUNCH;
if (!this->terminated_)
{
SysPanic("::Run called on system thread");
@ -320,15 +322,16 @@ namespace Aurora::Threading::Threads
}
this->terminated_->Reset();
auto copy = this->info_.callbacks;
return ExecuteNewOSContext([=]()
{
try
{
// this functional backends are being deprecated
if (this->info_.callbacks)
if (copy)
{
this->info_.callbacks->OnEntry(this);
copy->OnEntry(this);
}
}
catch (...)
@ -598,6 +601,8 @@ namespace Aurora::Threading::Threads
void OSThread::_ThreadEP()
{
AU_DEBUG_MEMCRUNCH;
// Poke TLS reference thread entity
// TODO: we need an internal OSThread *TryPokeTLSThread()
auto osThread = static_cast<OSThread *>(GetThread());
@ -629,6 +634,7 @@ namespace Aurora::Threading::Threads
if (auto task = task_)
{
this->epExecEvent->Set();
AU_DEBUG_REVERSE_MEMCRUNCH;
task();
}
}