[+] Catch around all async DispatchFrames. Will add optional forced panic later.

[*] Fix thread handle bug on non-au threads
This commit is contained in:
Reece Wilson 2022-10-14 07:14:56 +01:00
parent 278a128834
commit 48a8e4ae5a
3 changed files with 24 additions and 5 deletions

View File

@ -236,13 +236,22 @@ namespace Aurora::Async
void WorkItem::RunAsyncLocked()
{
IWorkItemHandler::ProcessInfo info(true);
info.pool = this->owner_->ToThreadPool();
if (this->task_)
{
this->task_->DispatchFrame(info);
try
{
this->task_->DispatchFrame(info);
}
catch (...)
{
// TODO: runtime config for root level exception caught behaviour
SysPushErrorCatch();
Fail();
return;
}
}
switch (info.type)

View File

@ -89,7 +89,6 @@ namespace Aurora::Threading::Threads
this->bNotOwned = true;
}
bool DeadTest();
OSThread::~OSThread()
@ -99,6 +98,10 @@ namespace Aurora::Threading::Threads
if (this->bNotOwned)
{
#if defined(AURORA_IS_MODERNNT_DERIVED)
auto hHandle = (HANDLE)this->handle_;
AuWin32CloseHandle(hHandle);
#endif
return;
}
@ -352,6 +355,7 @@ namespace Aurora::Threading::Threads
void OSThread::SetName(const AuString &name)
{
this->name_ = name;
this->UpdateName();
}
EThreadThrottle OSThread::GetThrottle()
@ -430,8 +434,14 @@ namespace Aurora::Threading::Threads
{
this->task_ = task;
this->handle_ = 0;
auto ret = SpawnThread([this]()
{
while (!this->handle_)
{
};
this->_ThreadEP();
}, GetName(), this->info_.stackSize);

View File

@ -42,9 +42,9 @@ namespace Aurora::Threading::Threads
HANDLE ret;
auto process = GetCurrentProcess();
auto thread = GetCurrentProcess();
auto thread = GetCurrentThread();
if (!DuplicateHandle(process, thread, process, &ret, DUPLICATE_SAME_ACCESS, FALSE, DUPLICATE_SAME_ACCESS))
if (!DuplicateHandle(process, thread, process, &ret, THREAD_ALL_ACCESS, FALSE, FALSE))
{
return reinterpret_cast<AuUInt64>(INVALID_HANDLE_VALUE);
}