[*] Leave the signal, dont callback

[*] ...and attach
[*] ...and check args
[*] ...and always check later at least once
This commit is contained in:
Reece Wilson 2024-01-05 12:55:19 +00:00
parent 6d77a55d75
commit 2ebf2811bd
2 changed files with 47 additions and 5 deletions

View File

@ -85,6 +85,12 @@ namespace Aurora::Processes
this->thread_.reset();
}
if (auto pGroup = this->pCompletionGroup_)
{
this->bHasTerminated = true;
pGroup->TryTrigger();
}
AuWin32CloseHandle(this->poke_);
this->process_ = INVALID_HANDLE_VALUE;
AuWin32CloseHandle(this->processInfo_.hProcess);
@ -767,11 +773,17 @@ namespace Aurora::Processes
if (auto pCompletionGroup = this->pCompletionGroup_)
{
pCompletionGroup->TryTrigger();
if (auto pTriggerSrc = pCompletionGroup->GetTriggerLoopSource())
{
pTriggerSrc->Set();
}
else
{
pCompletionGroup->TryTrigger();
}
}
};
this->thread_ = AuThreads::ThreadUnique(AuThreads::ThreadInfo(
AuMakeShared<AuThreads::IThreadVectorsFunctional>(AuThreads::IThreadVectorsFunctional::OnEntry_t(std::bind(a)),
AuThreads::IThreadVectorsFunctional::OnExit_t{})
@ -794,12 +806,20 @@ namespace Aurora::Processes
bool ProcessImpl::TryAttachProcessExitToCompletionGroup(const AuSPtr<IO::CompletionGroup::ICompletionGroup> &pCompletionGroup)
{
if (this->pCompletionGroup_)
if (this->pCompletionGroup_ ||
!pCompletionGroup)
{
return false;
}
this->pCompletionGroup_ = pCompletionGroup;
pCompletionGroup->AddWorkItem(AuUnsafeRaiiToShared(this));
if (auto pLoopSource = pCompletionGroup->GetTriggerLoopSource())
{
// verify the process hasnt already exited at least once
pLoopSource->Set();
}
return true;
}

View File

@ -117,6 +117,13 @@ namespace Aurora::Processes
AuTryRemove(gPidLookupMap, this->pidt_);
}
if (auto pGroup = this->pCompletionGroup_)
{
this->bHasExited = true;
pGroup->TryTrigger();
}
ShutdownPipes();
}
@ -157,7 +164,14 @@ namespace Aurora::Processes
if (auto pCompletionGroup = this->pCompletionGroup_)
{
pCompletionGroup->TryTrigger();
if (auto pTriggerSrc = pCompletionGroup->GetTriggerLoopSource())
{
pTriggerSrc->Set();
}
else
{
pCompletionGroup->TryTrigger();
}
}
}
@ -745,12 +759,20 @@ namespace Aurora::Processes
bool ProcessImpl::TryAttachProcessExitToCompletionGroup(const AuSPtr<IO::CompletionGroup::ICompletionGroup> &pCompletionGroup)
{
if (this->pCompletionGroup_)
if (this->pCompletionGroup_ ||
!pCompletionGroup)
{
return false;
}
this->pCompletionGroup_ = pCompletionGroup;
pCompletionGroup->AddWorkItem(AuUnsafeRaiiToShared(this));
if (auto pLoopSource = pCompletionGroup->GetTriggerLoopSource())
{
// verify the process hasnt already exited at least once
pLoopSource->Set();
}
return true;
}