2021-06-27 21:33:58 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: WorkItem.cpp
|
|
|
|
Date: 2021-6-26
|
|
|
|
Author: Reece
|
|
|
|
***/
|
2021-09-30 14:57:41 +00:00
|
|
|
#include <Source/RuntimeInternal.hpp>
|
2021-06-30 09:28:52 +00:00
|
|
|
#include "Async.hpp"
|
2021-06-27 21:25:29 +00:00
|
|
|
#include "WorkItem.hpp"
|
2021-06-30 09:28:52 +00:00
|
|
|
#include "AsyncApp.hpp"
|
2023-11-11 10:11:09 +00:00
|
|
|
#include "AuSchedular.hpp"
|
2023-12-07 09:20:23 +00:00
|
|
|
#include "ThreadPool.hpp"
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2023-08-30 00:28:05 +00:00
|
|
|
#if defined(AURORA_COMPILER_CLANG)
|
|
|
|
// warning: enumeration values 'kEnumCount' not handled in switch [-Wswitch
|
|
|
|
#pragma clang diagnostic ignored "-Wswitch"
|
|
|
|
// Yea, I don't give a shit.
|
|
|
|
#endif
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
namespace Aurora::Async
|
|
|
|
{
|
2023-01-23 21:18:58 +00:00
|
|
|
WorkItem::WorkItem(IThreadPoolInternal *owner,
|
2024-02-28 14:47:00 +00:00
|
|
|
AuOptional<WorkerPId_t> worker,
|
2023-08-10 02:34:44 +00:00
|
|
|
const AuSPtr<IWorkItemHandler> &task) :
|
2023-05-25 00:55:55 +00:00
|
|
|
worker_(worker), task_(task), owner_(owner),
|
|
|
|
finishedEvent_(false, true, true)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2024-01-23 22:35:18 +00:00
|
|
|
SysAssert(owner, "Unable to dispatch on an unspecified pool");
|
|
|
|
|
2023-10-24 14:33:30 +00:00
|
|
|
this->uShutdownCookie = owner->uAtomicShutdownCookie;
|
|
|
|
|
|
|
|
if (auto pWorker = this->GetState())
|
|
|
|
{
|
2023-11-11 10:11:09 +00:00
|
|
|
this->optOtherCookie = pWorker->shutdown.uShutdownFence;
|
2023-10-24 14:33:30 +00:00
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WorkItem::~WorkItem()
|
|
|
|
{
|
2023-12-01 09:22:51 +00:00
|
|
|
if (auto pIOWatch = AuExchange(this->pIOWatch, {}))
|
|
|
|
{
|
|
|
|
pIOWatch->StopWatch();
|
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 20:32:59 +00:00
|
|
|
AuSPtr<IWorkItem> WorkItem::WaitFor(const AuSPtr<IWorkItem> &workItem)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2021-06-30 09:41:58 +00:00
|
|
|
bool status {};
|
2021-06-27 21:25:29 +00:00
|
|
|
|
|
|
|
{
|
2022-02-19 11:43:57 +00:00
|
|
|
auto dependency = AuReinterpretCast<WorkItem>(workItem);
|
2021-06-30 09:41:58 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
AU_LOCK_GUARD(this->lock);
|
2021-09-06 10:58:08 +00:00
|
|
|
AU_LOCK_GUARD(dependency->lock);
|
2021-06-30 09:34:01 +00:00
|
|
|
|
|
|
|
if (dependency->HasFailed())
|
|
|
|
{
|
2022-05-17 00:59:19 +00:00
|
|
|
Fail();
|
|
|
|
return AU_SHARED_FROM_THIS;
|
2021-06-30 09:34:01 +00:00
|
|
|
}
|
|
|
|
|
2022-05-16 23:46:25 +00:00
|
|
|
if (!AuTryInsert(dependency->waiters_, AuSharedFromThis()))
|
|
|
|
{
|
2022-05-17 00:59:19 +00:00
|
|
|
Fail();
|
|
|
|
return AU_SHARED_FROM_THIS;
|
2022-05-16 23:46:25 +00:00
|
|
|
}
|
|
|
|
|
2024-03-04 11:55:54 +00:00
|
|
|
if (!AuTryInsert(this->waitOn_, AuConstReference(workItem)))
|
2022-05-16 23:46:25 +00:00
|
|
|
{
|
|
|
|
AuTryRemove(dependency->waiters_, AuSharedFromThis());
|
2022-05-17 00:59:19 +00:00
|
|
|
Fail();
|
|
|
|
return AU_SHARED_FROM_THIS;
|
2022-05-16 23:46:25 +00:00
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2021-06-30 09:41:58 +00:00
|
|
|
|
2021-07-07 20:32:59 +00:00
|
|
|
return AU_SHARED_FROM_THIS;
|
2021-06-30 09:41:58 +00:00
|
|
|
}
|
2021-07-12 14:37:05 +00:00
|
|
|
|
2022-05-16 23:41:27 +00:00
|
|
|
bool WorkItem::WaitForLocked(const AuList<AuSPtr<IWorkItem>> &workItems)
|
2021-06-30 09:41:58 +00:00
|
|
|
{
|
2022-05-16 23:41:27 +00:00
|
|
|
for (auto &workItem : workItems)
|
2021-06-30 09:41:58 +00:00
|
|
|
{
|
2023-05-02 10:27:06 +00:00
|
|
|
if (!workItem)
|
|
|
|
{
|
|
|
|
SysPushErrorArg();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-05-16 23:41:27 +00:00
|
|
|
auto dependency = AuReinterpretCast<WorkItem>(workItem);
|
|
|
|
AU_LOCK_GUARD(dependency->lock);
|
2021-06-30 09:41:58 +00:00
|
|
|
|
2022-05-16 23:41:27 +00:00
|
|
|
if (dependency->HasFailed())
|
2021-06-30 09:41:58 +00:00
|
|
|
{
|
2022-05-16 23:41:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-06-30 09:41:58 +00:00
|
|
|
|
2022-05-16 23:41:27 +00:00
|
|
|
if (!AuTryInsert(dependency->waiters_, AuSharedFromThis()))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2021-06-30 09:41:58 +00:00
|
|
|
|
2024-03-04 11:55:54 +00:00
|
|
|
if (!AuTryInsert(this->waitOn_, AuConstReference(workItem)))
|
2022-05-16 23:41:27 +00:00
|
|
|
{
|
|
|
|
AuTryRemove(dependency->waiters_, AuSharedFromThis());
|
|
|
|
return false;
|
2021-06-30 09:41:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-16 23:41:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuSPtr<IWorkItem> WorkItem::WaitFor(const AuList<AuSPtr<IWorkItem>> &workItems)
|
|
|
|
{
|
|
|
|
bool status {};
|
|
|
|
|
|
|
|
{
|
|
|
|
AU_LOCK_GUARD(this->lock);
|
|
|
|
status = WaitForLocked(workItems);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!status)
|
2021-06-30 09:41:58 +00:00
|
|
|
{
|
|
|
|
Fail();
|
|
|
|
}
|
2021-07-07 20:32:59 +00:00
|
|
|
|
|
|
|
return AU_SHARED_FROM_THIS;
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2021-07-12 14:37:05 +00:00
|
|
|
|
|
|
|
AuSPtr<IWorkItem> WorkItem::Then(const AuSPtr<IWorkItem> &next)
|
|
|
|
{
|
|
|
|
auto that = AU_SHARED_FROM_THIS;
|
2023-05-02 10:27:06 +00:00
|
|
|
if (!next)
|
|
|
|
{
|
|
|
|
SysPushErrorArg();
|
|
|
|
return {};
|
|
|
|
}
|
2021-07-12 14:37:05 +00:00
|
|
|
next->WaitFor(that);
|
|
|
|
next->Dispatch();
|
|
|
|
return that;
|
|
|
|
}
|
2021-06-30 12:00:32 +00:00
|
|
|
|
2021-07-07 20:32:59 +00:00
|
|
|
AuSPtr<IWorkItem> WorkItem::SetSchedTimeNs(AuUInt64 ns)
|
2021-06-30 12:00:32 +00:00
|
|
|
{
|
2023-08-09 02:21:14 +00:00
|
|
|
this->dispatchTimeNs_ = Time::SteadyClockNS() + ns;
|
2021-11-05 17:34:23 +00:00
|
|
|
return AU_SHARED_FROM_THIS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuSPtr<IWorkItem> WorkItem::SetSchedTimeAbs(AuUInt32 ms)
|
|
|
|
{
|
2023-08-09 02:21:14 +00:00
|
|
|
return this->SetSchedTimeNsAbs(AuMSToNS<AuUInt64>(ms));
|
2021-11-05 17:34:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AuSPtr<IWorkItem> WorkItem::SetSchedTimeNsAbs(AuUInt64 ns)
|
|
|
|
{
|
2023-08-09 02:21:14 +00:00
|
|
|
auto uNow = AuTime::CurrentClockNS();
|
|
|
|
if (uNow > ns)
|
|
|
|
{
|
|
|
|
return AU_SHARED_FROM_THIS;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->dispatchTimeNs_ = AuTime::SteadyClockNS() + (ns - uNow);
|
|
|
|
return AU_SHARED_FROM_THIS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuSPtr<IWorkItem> WorkItem::SetSchedSteadyTimeNsAbs(AuUInt64 ns)
|
|
|
|
{
|
|
|
|
this->dispatchTimeNs_ = ns;
|
2021-07-07 20:32:59 +00:00
|
|
|
return AU_SHARED_FROM_THIS;
|
2021-06-30 12:00:32 +00:00
|
|
|
}
|
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
AuSPtr<IWorkItem> WorkItem::SetSchedByLoopSourceRepeating(const AuSPtr<IO::Loop::ILoopSource> &pLoopSource)
|
2023-12-01 09:22:51 +00:00
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
if (this->pIOWatchLS)
|
|
|
|
{
|
|
|
|
this->Fail();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
this->bIoRepeating = true;
|
|
|
|
this->pIOWatchLS = pLoopSource;
|
|
|
|
return AU_SHARED_FROM_THIS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuSPtr<IWorkItem> WorkItem::SetSchedByLoopSourceOnce(const AuSPtr<IO::Loop::ILoopSource> &pLoopSource)
|
|
|
|
{
|
|
|
|
if (this->pIOWatchLS)
|
|
|
|
{
|
|
|
|
this->Fail();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
this->bIoRepeating = false;
|
2023-12-01 09:22:51 +00:00
|
|
|
this->pIOWatchLS = pLoopSource;
|
|
|
|
return AU_SHARED_FROM_THIS;
|
|
|
|
}
|
|
|
|
|
2021-07-07 20:32:59 +00:00
|
|
|
AuSPtr<IWorkItem> WorkItem::SetSchedTime(AuUInt32 ms)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2023-08-09 02:21:14 +00:00
|
|
|
this->dispatchTimeNs_ = Time::SteadyClockNS() + AuMSToNS<AuUInt64>(ms);
|
2021-07-07 20:32:59 +00:00
|
|
|
return AU_SHARED_FROM_THIS;
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2021-07-15 16:16:23 +00:00
|
|
|
|
|
|
|
AuSPtr<IWorkItem> WorkItem::AddDelayTime(AuUInt32 ms)
|
|
|
|
{
|
2022-06-12 18:23:18 +00:00
|
|
|
this->delayTimeNs_ += AuMSToNS<AuUInt64>(ms);
|
2021-07-15 16:16:23 +00:00
|
|
|
return AU_SHARED_FROM_THIS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuSPtr<IWorkItem> WorkItem::AddDelayTimeNs(AuUInt64 ns)
|
|
|
|
{
|
2021-11-05 17:34:23 +00:00
|
|
|
this->delayTimeNs_ += ns;
|
2021-07-15 16:16:23 +00:00
|
|
|
return AU_SHARED_FROM_THIS;
|
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2024-02-27 12:24:17 +00:00
|
|
|
AuSPtr<IWorkItem> WorkItem::AddDelayTimeRepeating(AuUInt32 ms)
|
|
|
|
{
|
|
|
|
this->delayTimeNs_ += AuMSToNS<AuUInt64>(ms);
|
|
|
|
this->bRepeatingTimer = true;
|
|
|
|
return AU_SHARED_FROM_THIS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuSPtr<IWorkItem> WorkItem::AddDelayTimeNsRepeating(AuUInt64 ns)
|
|
|
|
{
|
|
|
|
this->bRepeatingTimer = true;
|
|
|
|
this->delayTimeNs_ += ns;
|
|
|
|
return AU_SHARED_FROM_THIS;
|
|
|
|
}
|
|
|
|
|
2021-07-07 20:32:59 +00:00
|
|
|
AuSPtr<IWorkItem> WorkItem::Dispatch()
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
|
|
|
DispatchEx(false);
|
2021-07-07 20:32:59 +00:00
|
|
|
return AU_SHARED_FROM_THIS;
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
void WorkItem::DispatchEx(bool check, bool bIsIOTick)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2023-02-08 18:23:37 +00:00
|
|
|
AU_LOCK_GUARD(this->lock);
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2022-05-16 23:41:27 +00:00
|
|
|
DispatchExLocked(check);
|
|
|
|
}
|
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
void WorkItem::DispatchExLocked(bool check, bool bIsIOTick)
|
2022-05-16 23:41:27 +00:00
|
|
|
{
|
2021-06-27 21:25:29 +00:00
|
|
|
if (check)
|
|
|
|
{
|
2021-11-05 17:34:23 +00:00
|
|
|
if (this->dispatchPending_)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-30 09:34:01 +00:00
|
|
|
if (HasFailed())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
for (auto itr = this->waitOn_.begin(); itr != this->waitOn_.end(); )
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
|
|
|
auto &waitable = *itr;
|
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
if (AuStaticCast<WorkItem>(waitable)->HasFinishedRepeatable())
|
|
|
|
{
|
|
|
|
// noop
|
|
|
|
}
|
|
|
|
else if (waitable->HasFinished())
|
|
|
|
{
|
|
|
|
itr = this->waitOn_.erase(itr);
|
|
|
|
}
|
2024-05-02 19:06:41 +00:00
|
|
|
else if (waitable->HasFailed())
|
|
|
|
{
|
|
|
|
itr = this->waitOn_.erase(itr);
|
|
|
|
this->Fail();
|
|
|
|
return;
|
|
|
|
}
|
2024-02-27 11:03:42 +00:00
|
|
|
else
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
this->dispatchPending_ = true;
|
2021-09-06 10:58:08 +00:00
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
if (this->ioTickCount)
|
|
|
|
{
|
|
|
|
// Bypass IO tick check / I owe you
|
|
|
|
}
|
|
|
|
else if (!bIsIOTick && this->pIOWatchLS)
|
2023-12-01 09:22:51 +00:00
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
if (this->pIOWatchLS &&
|
|
|
|
!this->pIOWatch && // should sched?
|
|
|
|
!this->pIOWatchLS->IsSignaled()) // fast path to avoid scheduling
|
2023-12-01 09:22:51 +00:00
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
// Try schedule outside of an IO tick
|
2023-12-01 09:22:51 +00:00
|
|
|
if (!Schedule())
|
|
|
|
{
|
|
|
|
this->Fail();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2024-02-27 11:03:42 +00:00
|
|
|
else if (!this->pIOWatchLS->IsSignaled()) // fast path to avoid bailing out
|
2023-12-01 09:22:51 +00:00
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
return;
|
2023-12-01 09:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
if (bIsIOTick)
|
|
|
|
{
|
|
|
|
this->ioTickCount++;
|
|
|
|
}
|
|
|
|
|
2023-08-09 02:21:14 +00:00
|
|
|
if (Time::SteadyClockNS() < this->dispatchTimeNs_)
|
2021-07-15 16:16:23 +00:00
|
|
|
{
|
2022-08-13 21:59:44 +00:00
|
|
|
if (!Schedule())
|
|
|
|
{
|
|
|
|
this->Fail();
|
|
|
|
}
|
2021-07-15 16:16:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-02-27 12:24:17 +00:00
|
|
|
|
|
|
|
if (auto delay = this->delayTimeNs_)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2023-08-09 02:21:14 +00:00
|
|
|
this->dispatchTimeNs_ = delay + Time::SteadyClockNS();
|
2024-02-27 12:24:17 +00:00
|
|
|
|
|
|
|
if (!this->bRepeatingTimer)
|
|
|
|
{
|
|
|
|
this->delayTimeNs_ = 0;
|
|
|
|
}
|
|
|
|
|
2022-08-13 21:59:44 +00:00
|
|
|
if (!Schedule())
|
|
|
|
{
|
|
|
|
this->Fail();
|
|
|
|
}
|
2024-02-27 12:24:17 +00:00
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
if (this->ioTickCount)
|
|
|
|
{
|
|
|
|
this->ioTickCount--;
|
|
|
|
}
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
SendOff();
|
|
|
|
}
|
|
|
|
|
2023-12-07 09:20:23 +00:00
|
|
|
EWorkPriority WorkItem::GetPrio()
|
2021-11-05 17:34:23 +00:00
|
|
|
{
|
2023-05-25 00:55:55 +00:00
|
|
|
return this->prio_;
|
2021-11-05 17:34:23 +00:00
|
|
|
}
|
|
|
|
|
2023-12-07 09:20:23 +00:00
|
|
|
void WorkItem::SetPrio(EWorkPriority prio)
|
2021-11-05 17:34:23 +00:00
|
|
|
{
|
2023-12-07 09:20:23 +00:00
|
|
|
if (!EWorkPriorityIsValid(prio))
|
|
|
|
{
|
|
|
|
SysPushErrorArg();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-25 00:55:55 +00:00
|
|
|
this->prio_ = prio;
|
2021-11-05 17:34:23 +00:00
|
|
|
}
|
|
|
|
|
2021-06-30 09:28:52 +00:00
|
|
|
void WorkItem::CancelAsync()
|
|
|
|
{
|
2023-12-07 09:20:23 +00:00
|
|
|
AU_LOCK_GUARD(this->lock2);
|
2023-10-24 14:33:30 +00:00
|
|
|
this->Fail();
|
|
|
|
}
|
|
|
|
|
|
|
|
AuOptional<AuPair<AuUInt32, AuUInt32>> WorkItem::QueryFences()
|
|
|
|
{
|
|
|
|
return AuPair<AuUInt32, AuUInt32>{ this->uShutdownCookie, this->optOtherCookie.ValueOr(0) };
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WorkItem::CheckAlive()
|
|
|
|
{
|
|
|
|
if (this->owner_ &&
|
|
|
|
this->uShutdownCookie != this->owner_->uAtomicShutdownCookie)
|
|
|
|
{
|
|
|
|
this->Fail();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->optOtherCookie)
|
|
|
|
{
|
|
|
|
if (auto pWorker = this->GetState())
|
|
|
|
{
|
2023-11-11 10:11:09 +00:00
|
|
|
if (this->optOtherCookie.value() != pWorker->shutdown.uShutdownFence)
|
2023-10-24 14:33:30 +00:00
|
|
|
{
|
|
|
|
this->Fail();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2021-06-30 09:28:52 +00:00
|
|
|
}
|
|
|
|
|
2023-08-10 02:34:44 +00:00
|
|
|
void WorkItem::DispatchTask(IWorkItemHandler::ProcessInfo &info)
|
2023-02-08 18:23:37 +00:00
|
|
|
{
|
2023-10-24 14:33:30 +00:00
|
|
|
if (!this->CheckAlive())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
bool bRerun = (this->pIOWatchLS && this->bIoRepeating) ||
|
2024-02-27 12:24:17 +00:00
|
|
|
this->waitOn_.size() ||
|
|
|
|
this->bRepeatingTimer;
|
2024-02-27 11:03:42 +00:00
|
|
|
|
|
|
|
if (bRerun)
|
|
|
|
{
|
|
|
|
info = ETickType::eScheduleAndNotifyRepeatingWaiters;
|
|
|
|
}
|
|
|
|
|
2023-02-08 18:23:37 +00:00
|
|
|
if (this->task_)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
this->task_->DispatchFrame(info);
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
// TODO: runtime config for root level exception caught behaviour
|
|
|
|
SysPushErrorCatch();
|
2023-10-24 14:33:30 +00:00
|
|
|
this->Fail();
|
2023-02-08 18:23:37 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2023-08-10 02:34:44 +00:00
|
|
|
}
|
|
|
|
|
2023-12-07 09:20:23 +00:00
|
|
|
void WorkItem::Cleanup()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-10-24 14:33:30 +00:00
|
|
|
AuSPtr<ThreadState> WorkItem::GetState()
|
|
|
|
{
|
2023-12-01 09:22:51 +00:00
|
|
|
if (this->worker_.HasValue())
|
|
|
|
{
|
|
|
|
return this->owner_->GetThreadHandle(this->worker_.value());
|
|
|
|
}
|
|
|
|
else
|
2023-10-24 14:33:30 +00:00
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-10 02:34:44 +00:00
|
|
|
void WorkItem::RunAsyncLocked2()
|
|
|
|
{
|
|
|
|
AU_LOCK_GUARD(this->lock2);
|
2023-02-08 18:23:37 +00:00
|
|
|
|
2023-08-10 02:34:44 +00:00
|
|
|
IWorkItemHandler::ProcessInfo info(true);
|
|
|
|
info.pool = this->owner_->ToThreadPool();
|
|
|
|
|
|
|
|
DispatchTask(info);
|
|
|
|
|
2023-02-08 18:23:37 +00:00
|
|
|
RunAsyncLocked2(info);
|
|
|
|
}
|
|
|
|
|
2021-06-30 09:28:52 +00:00
|
|
|
void WorkItem::RunAsync()
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2023-02-08 18:23:37 +00:00
|
|
|
AU_LOCK_GUARD(this->lock2);
|
2022-05-17 01:43:26 +00:00
|
|
|
RunAsyncLocked();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WorkItem::RunAsyncLocked()
|
|
|
|
{
|
2021-06-27 21:25:29 +00:00
|
|
|
IWorkItemHandler::ProcessInfo info(true);
|
2021-11-05 17:34:23 +00:00
|
|
|
info.pool = this->owner_->ToThreadPool();
|
2021-09-06 10:58:08 +00:00
|
|
|
|
2023-09-22 05:05:39 +00:00
|
|
|
DispatchTask(info);
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2023-02-08 18:23:37 +00:00
|
|
|
AU_LOCK_GUARD(this->lock);
|
|
|
|
RunAsyncLocked2(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WorkItem::RunAsyncLocked2(const IWorkItemHandler::ProcessInfo &info)
|
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
if (info.type != ETickType::eScheduleAndNotifyRepeatingWaiters &&
|
|
|
|
info.type != ETickType::eRerunAndNotifyRepeatingWaiters)
|
|
|
|
{
|
|
|
|
if (auto pIOWatch = AuExchange(this->pIOWatch, {}))
|
|
|
|
{
|
|
|
|
pIOWatch->StopWatch();
|
|
|
|
}
|
|
|
|
|
|
|
|
AuResetMember(this->pIOWatchLS);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->finished2 = false;
|
2023-02-08 18:23:37 +00:00
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
switch (info.type)
|
|
|
|
{
|
2022-05-16 23:41:27 +00:00
|
|
|
case ETickType::eFinished:
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-05-17 01:43:26 +00:00
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
// do nothing
|
|
|
|
break;
|
|
|
|
}
|
2022-05-16 23:41:27 +00:00
|
|
|
case ETickType::eEnumInvalid:
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
|
|
|
SysPanic("Handle Invalid");
|
|
|
|
break;
|
|
|
|
}
|
2022-05-16 23:41:27 +00:00
|
|
|
case ETickType::eSchedule:
|
2024-02-27 11:03:42 +00:00
|
|
|
case ETickType::eScheduleAndNotifyRepeatingWaiters:
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
|
|
|
if (info.reschedMs)
|
|
|
|
{
|
|
|
|
SetSchedTime(info.reschedMs);
|
2021-11-08 00:11:01 +00:00
|
|
|
}
|
|
|
|
else if (info.reschedNs)
|
2021-06-30 12:00:32 +00:00
|
|
|
{
|
|
|
|
SetSchedTimeNs(info.reschedNs);
|
|
|
|
}
|
2021-11-08 00:11:01 +00:00
|
|
|
else if (info.reschedClockAbsMs)
|
|
|
|
{
|
2023-10-31 21:07:42 +00:00
|
|
|
SetSchedTimeAbs(info.reschedClockAbsMs);
|
2021-11-08 00:11:01 +00:00
|
|
|
}
|
|
|
|
else if (info.reschedClockAbsNs)
|
|
|
|
{
|
2023-10-31 21:07:42 +00:00
|
|
|
SetSchedTimeNsAbs(info.reschedClockAbsNs);
|
|
|
|
}
|
|
|
|
else if (info.reschedSteadyClockAbsNs)
|
|
|
|
{
|
|
|
|
SetSchedSteadyTimeNsAbs(info.reschedSteadyClockAbsNs);
|
2021-11-08 00:11:01 +00:00
|
|
|
}
|
2023-12-01 09:22:51 +00:00
|
|
|
else if (info.pLoopSource)
|
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
SetSchedByLoopSourceOnce(info.pLoopSource);
|
2023-12-01 09:22:51 +00:00
|
|
|
}
|
2022-05-16 23:41:27 +00:00
|
|
|
|
|
|
|
if (!WaitForLocked(info.waitFor))
|
|
|
|
{
|
2023-10-24 14:33:30 +00:00
|
|
|
this->Fail();
|
2022-05-16 23:41:27 +00:00
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2021-06-30 09:34:01 +00:00
|
|
|
[[fallthrough]];
|
2022-05-16 23:41:27 +00:00
|
|
|
case ETickType::eRerun:
|
2024-02-27 11:03:42 +00:00
|
|
|
case ETickType::eRerunAndNotifyRepeatingWaiters:
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
DispatchEx(false);
|
|
|
|
|
|
|
|
if (info.type == ETickType::eRerun ||
|
|
|
|
info.type == ETickType::eSchedule)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->finished2 = true;
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2022-05-16 23:41:27 +00:00
|
|
|
case ETickType::eFailed:
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2023-10-24 14:33:30 +00:00
|
|
|
this->Fail();
|
2021-06-27 21:25:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
this->dispatchPending_ = false;
|
2023-12-01 09:22:51 +00:00
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
this->finished = !this->finished2;
|
|
|
|
|
|
|
|
this->finishedEvent_->Set();
|
2021-09-06 10:58:08 +00:00
|
|
|
|
2023-12-01 09:22:51 +00:00
|
|
|
for (auto &waiter : AuExchange(this->waiters_, {}))
|
2021-09-06 10:58:08 +00:00
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
AuReinterpretCast<WorkItem>(waiter)->DispatchEx(true);
|
2021-09-06 10:58:08 +00:00
|
|
|
}
|
2023-12-01 09:22:51 +00:00
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
if (this->finished2)
|
2023-12-01 09:22:51 +00:00
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
this->finished2 = false;
|
|
|
|
this->finishedEvent_->Reset();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->Cleanup();
|
2023-12-01 09:22:51 +00:00
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WorkItem::Fail()
|
|
|
|
{
|
|
|
|
failed = true;
|
|
|
|
|
2023-12-01 09:22:51 +00:00
|
|
|
if (auto pIOWatch = AuExchange(this->pIOWatch, {}))
|
|
|
|
{
|
|
|
|
pIOWatch->StopWatch();
|
|
|
|
}
|
|
|
|
|
|
|
|
AuResetMember(this->pIOWatchLS);
|
|
|
|
|
2022-01-19 17:08:13 +00:00
|
|
|
if (auto task_ = AuExchange(this->task_, {}))
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-05-16 23:41:27 +00:00
|
|
|
task_->OnFailure();
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
for (auto &waiter : this->waiters_)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-02-19 11:50:14 +00:00
|
|
|
AuReinterpretCast<WorkItem>(waiter)->Fail();
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
this->waiters_.clear();
|
|
|
|
this->waitOn_.clear();
|
2023-12-07 09:20:23 +00:00
|
|
|
|
|
|
|
this->Cleanup();
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
if (this->finishedEvent_)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2021-11-05 17:34:23 +00:00
|
|
|
this->finishedEvent_->Set();
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WorkItem::BlockUntilComplete()
|
|
|
|
{
|
2024-05-02 19:06:41 +00:00
|
|
|
#if 0
|
2023-09-22 05:05:39 +00:00
|
|
|
if (!this->worker_)
|
2024-05-02 19:06:41 +00:00
|
|
|
#else
|
|
|
|
if (!this->worker_ && !AuAsync::GetCurrentWorkerPId())
|
|
|
|
#endif
|
2023-09-22 05:05:39 +00:00
|
|
|
{
|
|
|
|
this->finishedEvent_->Wait();
|
|
|
|
return true;
|
2023-11-12 00:18:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct WaitProxy : Threading::IWaitable
|
|
|
|
{
|
|
|
|
AuThreadPrimitives::IEvent *pEvent {};
|
|
|
|
WaitProxy(AuThreadPrimitives::IEvent *pEvent) :
|
|
|
|
pEvent(pEvent)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
bool HasOSHandle(AuMach &mach) override
|
|
|
|
{
|
|
|
|
return this->pEvent->HasOSHandle(mach);
|
|
|
|
}
|
|
|
|
bool HasLockImplementation() override
|
|
|
|
{
|
|
|
|
return this->pEvent->HasLockImplementation();
|
|
|
|
}
|
|
|
|
void Lock() override
|
|
|
|
{
|
|
|
|
return this->pEvent->Lock();
|
|
|
|
}
|
|
|
|
bool LockMS(AuUInt64 qwRelTimeoutInMs) override
|
|
|
|
{
|
|
|
|
return this->pEvent->LockMS(qwRelTimeoutInMs);
|
|
|
|
}
|
|
|
|
bool LockNS(AuUInt64 qwRelTimeoutInNs) override
|
|
|
|
{
|
|
|
|
return this->pEvent->LockNS(qwRelTimeoutInNs);
|
|
|
|
}
|
|
|
|
bool LockAbsMS(AuUInt64 qwAbsTimeoutInMs) override
|
|
|
|
{
|
|
|
|
return this->pEvent->LockAbsMS(qwAbsTimeoutInMs);
|
|
|
|
}
|
|
|
|
bool LockAbsNS(AuUInt64 qwAbsTimeoutInNs) override
|
|
|
|
{
|
|
|
|
return this->pEvent->LockAbsNS(qwAbsTimeoutInNs);
|
|
|
|
}
|
|
|
|
bool TryLock() override
|
|
|
|
{
|
|
|
|
return this->pEvent->TryLock();
|
|
|
|
}
|
|
|
|
void Unlock() override
|
|
|
|
{
|
|
|
|
// PATCH: ensure release notifications set the event!
|
|
|
|
this->pEvent->Set();
|
|
|
|
}
|
|
|
|
} waitProxy(this->finishedEvent_.AsPointer());
|
|
|
|
|
2024-05-02 19:06:41 +00:00
|
|
|
return this->owner_->WaitFor(this->worker_.ValueOr(WorkerPId_t {}),
|
2023-11-12 00:18:34 +00:00
|
|
|
AuUnsafeRaiiToShared(&waitProxy),
|
|
|
|
0 /*forever*/);
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2024-02-27 11:03:42 +00:00
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
bool WorkItem::HasFinished()
|
|
|
|
{
|
2021-11-05 17:34:23 +00:00
|
|
|
return this->finished;
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
bool WorkItem::HasFinishedRepeatable()
|
|
|
|
{
|
|
|
|
return this->finished2;
|
|
|
|
}
|
|
|
|
|
2021-09-29 08:01:42 +00:00
|
|
|
void WorkItem::Cancel()
|
|
|
|
{
|
2023-02-08 18:23:37 +00:00
|
|
|
AU_LOCK_GUARD(this->lock2);
|
2021-09-29 08:01:42 +00:00
|
|
|
Fail();
|
|
|
|
}
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
bool WorkItem::HasFailed()
|
|
|
|
{
|
2021-11-05 17:34:23 +00:00
|
|
|
return this->failed;
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2022-08-13 21:59:44 +00:00
|
|
|
bool WorkItem::Schedule()
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2023-12-01 09:22:51 +00:00
|
|
|
if (auto pLoopSource = this->pIOWatchLS)
|
|
|
|
{
|
2024-02-28 14:47:00 +00:00
|
|
|
AuSPtr<AuIO::IIOProcessor> pIOProcessor;
|
|
|
|
|
2023-12-01 09:22:51 +00:00
|
|
|
if (this->pIOWatch)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto pState = this->GetState();
|
|
|
|
if (!pState)
|
|
|
|
{
|
2024-02-28 14:47:00 +00:00
|
|
|
pIOProcessor = this->owner_->ToThreadPool()->GetIOProcessor(AuAsync::GetCurrentWorkerPId());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pIOProcessor = pState->singletons.GetIOProcessor(this->worker_.value());
|
2023-12-01 09:22:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pIOProcessor)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2024-02-27 11:03:42 +00:00
|
|
|
|
|
|
|
AU_DEBUG_MEMCRUNCH;
|
|
|
|
AuWPtr<WorkItem> wptr = this->SharedFromThis();
|
2023-12-01 09:22:51 +00:00
|
|
|
|
2024-02-27 11:03:42 +00:00
|
|
|
this->pIOWatch = pIOProcessor->StartSimpleLSWatchEx(pLoopSource, AuMakeSharedThrow<AuIO::IIOSimpleEventListenerFunctional>([=]()
|
2023-12-01 09:22:51 +00:00
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
if (auto pThat = AuTryLockMemoryType(wptr))
|
|
|
|
{
|
|
|
|
pThat->DispatchEx(false, true);
|
|
|
|
}
|
2023-12-01 09:22:51 +00:00
|
|
|
}, [=]()
|
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
if (auto pThat = AuTryLockMemoryType(wptr))
|
|
|
|
{
|
|
|
|
pThat->DispatchEx(false, true);
|
|
|
|
}
|
2023-12-01 09:22:51 +00:00
|
|
|
}, [=]()
|
|
|
|
{
|
2024-02-27 11:03:42 +00:00
|
|
|
if (auto pThat = AuTryLockMemoryType(wptr))
|
|
|
|
{
|
|
|
|
pThat->DispatchEx(false, true);
|
|
|
|
}
|
|
|
|
}), !this->bIoRepeating);
|
2023-12-01 09:22:51 +00:00
|
|
|
|
|
|
|
if (!this->pIOWatch)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Async::Schedule(this->dispatchTimeNs_, this->owner_, this->worker_.value(), AuSharedFromThis());
|
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WorkItem::SendOff()
|
|
|
|
{
|
2023-09-22 05:05:39 +00:00
|
|
|
if (!this->worker_)
|
2021-10-06 13:48:28 +00:00
|
|
|
{
|
|
|
|
// If we aren't actually calling a task interface, we may as well just dispatch objects waiting on us from here
|
2023-02-08 18:23:37 +00:00
|
|
|
RunAsyncLocked2();
|
2021-10-06 13:48:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-09-22 05:05:39 +00:00
|
|
|
this->owner_->Run(this->worker_.value(), AuSharedFromThis());
|
2021-10-06 13:48:28 +00:00
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2023-12-07 09:20:23 +00:00
|
|
|
|
|
|
|
void *WorkItem::GetPrivateData()
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2023-12-07 09:20:23 +00:00
|
|
|
if (!this->task_)
|
2023-10-24 14:33:30 +00:00
|
|
|
{
|
2023-12-07 09:20:23 +00:00
|
|
|
return nullptr;
|
2023-10-24 14:33:30 +00:00
|
|
|
}
|
2023-12-07 09:20:23 +00:00
|
|
|
|
|
|
|
return this->task_->GetPrivateData();
|
|
|
|
}
|
2023-10-24 14:33:30 +00:00
|
|
|
|
2023-12-07 09:20:23 +00:00
|
|
|
inline auto ToInternal(const AuSPtr<IThreadPool> &pool)
|
|
|
|
{
|
|
|
|
return AuStaticPointerCast<ThreadPool>(pool);
|
2023-08-10 02:34:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerId_t &worker, const AuSPtr<IWorkItemHandler> &task)
|
|
|
|
{
|
|
|
|
AU_DEBUG_MEMCRUNCH;
|
|
|
|
|
2021-10-06 13:48:28 +00:00
|
|
|
if (!task)
|
|
|
|
{
|
2022-06-22 13:42:17 +00:00
|
|
|
SysPushErrorArg("WorkItem has null task. Running out of memory?");
|
2021-10-06 13:48:28 +00:00
|
|
|
return {};
|
|
|
|
}
|
2021-11-05 17:34:23 +00:00
|
|
|
|
2023-12-07 09:20:23 +00:00
|
|
|
auto pWorker = GetCurrentWorkerPId().GetPool();
|
2023-09-15 15:53:18 +00:00
|
|
|
if (!pWorker)
|
|
|
|
{
|
2023-09-15 17:08:02 +00:00
|
|
|
pWorker = AuUnsafeRaiiToShared(static_cast<IAsyncApp *>(gAsyncApp));
|
2023-09-15 15:53:18 +00:00
|
|
|
}
|
|
|
|
|
2023-09-15 15:41:10 +00:00
|
|
|
return AuMakeShared<WorkItem>(ToInternal(pWorker).get(), WorkerPId_t { pWorker , worker }, task);
|
2021-11-05 17:34:23 +00:00
|
|
|
}
|
|
|
|
|
2023-08-10 02:34:44 +00:00
|
|
|
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerPId_t &worker, const AuSPtr<IWorkItemHandler> &task)
|
|
|
|
{
|
|
|
|
AU_DEBUG_MEMCRUNCH;
|
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
if (!task)
|
|
|
|
{
|
2022-06-22 13:42:17 +00:00
|
|
|
SysPushErrorArg("WorkItem has null task. Running out of memory?");
|
2021-11-05 17:34:23 +00:00
|
|
|
return {};
|
|
|
|
}
|
2023-09-15 15:53:18 +00:00
|
|
|
|
2023-12-07 09:20:23 +00:00
|
|
|
auto pWorker = worker.GetPool();
|
2023-09-15 15:53:18 +00:00
|
|
|
if (!pWorker)
|
|
|
|
{
|
2023-12-07 09:20:23 +00:00
|
|
|
pWorker = GetCurrentWorkerPId().GetPool();
|
2023-09-15 15:53:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pWorker)
|
|
|
|
{
|
2023-09-15 17:08:02 +00:00
|
|
|
pWorker = AuUnsafeRaiiToShared(static_cast<IAsyncApp *>(gAsyncApp));
|
2023-09-15 15:53:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return AuMakeSharedThrow<WorkItem>(ToInternal(pWorker).get(), worker, task);
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2021-10-06 13:48:28 +00:00
|
|
|
|
|
|
|
AUKN_SYM AuSPtr<IWorkItem> NewFence()
|
|
|
|
{
|
2023-12-07 09:20:23 +00:00
|
|
|
auto pWorker = GetCurrentWorkerPId().GetPool();
|
2023-09-15 15:53:18 +00:00
|
|
|
if (!pWorker)
|
|
|
|
{
|
2023-09-15 17:08:02 +00:00
|
|
|
pWorker = AuUnsafeRaiiToShared(static_cast<IAsyncApp *>(gAsyncApp));
|
2023-09-15 15:53:18 +00:00
|
|
|
}
|
2024-02-28 14:47:00 +00:00
|
|
|
return AuMakeShared<WorkItem>((IThreadPoolInternal *)ToInternal(pWorker).get(), AuOptional<WorkerPId_t> {}, AuSPtr<IWorkItemHandler>{});
|
2021-10-06 13:48:28 +00:00
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|