[*] Adjust PId_t::pool null behaviour
This commit is contained in:
parent
3ba93439c8
commit
addd4080b2
@ -25,7 +25,6 @@ namespace Aurora::Async
|
||||
///
|
||||
AUKN_SYM WorkerPId_t GetCurrentWorkerPId();
|
||||
|
||||
/// Async app only | Thread pools must use the IThreadPool::NewFence function
|
||||
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerId_t &worker, const AuSPtr<IWorkItemHandler> &task);
|
||||
|
||||
/**
|
||||
@ -47,9 +46,7 @@ namespace Aurora::Async
|
||||
/// Async app only | Thread pools must use the IThreadPool::NewFence function
|
||||
AUKN_SYM AuSPtr<IWorkItem> NewFence();
|
||||
|
||||
/// Allocates a new thread pool for usage
|
||||
AUKN_SYM AuSPtr<IThreadPool> NewThreadPool();
|
||||
///
|
||||
|
||||
AUKN_SYM void SetMainThreadForSysPumpScheduling(WorkerPId_t pid);
|
||||
}
|
||||
|
@ -80,6 +80,9 @@ namespace Aurora::Async
|
||||
inline WorkerPId_t(const AuSPtr<IThreadPool> &pool, const WorkerId_t &cpy) : WorkerId_t(cpy.first, cpy.second), pool(pool)
|
||||
{}
|
||||
|
||||
inline WorkerPId_t(ThreadGroup_t group, ThreadId_t id) : WorkerId_t(group, id)
|
||||
{ }
|
||||
|
||||
AuSPtr<IThreadPool> pool;
|
||||
|
||||
inline AuUInt HashCode() const noexcept
|
||||
@ -91,10 +94,5 @@ namespace Aurora::Async
|
||||
{
|
||||
return in.pool == this->pool && in.first == this->first && this->second == in.second;
|
||||
}
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
return pool;
|
||||
}
|
||||
};
|
||||
}
|
@ -71,7 +71,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
SysAssert(this->pid == AuAsync::GetCurrentWorkerPId());
|
||||
SysAssert(this->pid.value() == AuAsync::GetCurrentWorkerPId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
SysAssert(this->pid == AuAsync::GetCurrentWorkerPId());
|
||||
SysAssert(this->pid.value() == AuAsync::GetCurrentWorkerPId());
|
||||
}
|
||||
|
||||
this->onFailure = onFailure;
|
||||
@ -216,7 +216,7 @@ private:
|
||||
|
||||
void SubmitComplete()
|
||||
{
|
||||
if (AuAsync::GetCurrentWorkerPId() == this->pid)
|
||||
if (AuAsync::GetCurrentWorkerPId() == this->pid.value())
|
||||
{
|
||||
if (!this->onFailure && !this->callback)
|
||||
{
|
||||
|
@ -453,18 +453,9 @@ namespace Aurora::Async
|
||||
this->owner_->Run(this->worker_, AuSharedFromThis());
|
||||
}
|
||||
}
|
||||
static auto GetWorkerInternal()
|
||||
{
|
||||
return static_cast<AsyncApp *>(GetAsyncApp());
|
||||
}
|
||||
|
||||
inline auto GetWorkerInternal(const AuSPtr<IThreadPool> &pool)
|
||||
inline auto ToInternal(const AuSPtr<IThreadPool> &pool)
|
||||
{
|
||||
if (pool.get() == AuStaticCast<IAsyncApp>(gAsyncApp))
|
||||
{
|
||||
return AuUnsafeRaiiToShared(AuStaticCast<ThreadPool>(gAsyncApp));
|
||||
}
|
||||
|
||||
return AuStaticPointerCast<ThreadPool>(pool);
|
||||
}
|
||||
|
||||
@ -486,7 +477,9 @@ namespace Aurora::Async
|
||||
return {};
|
||||
}
|
||||
|
||||
return AuMakeShared<WorkItem>(GetWorkerInternal(), WorkerPId_t { AuAsync::GetCurrentWorkerPId().pool, worker }, task);
|
||||
auto pWorker = GetCurrentWorkerPId().pool;
|
||||
if (!pWorker) AuUnsafeRaiiToShared(gAsyncApp);
|
||||
return AuMakeShared<WorkItem>(ToInternal(pWorker).get(), WorkerPId_t { pWorker , worker }, task);
|
||||
}
|
||||
|
||||
AUKN_SYM AuSPtr<IWorkItem> NewWorkFunction(const WorkerPId_t &worker, AuVoidFunc func)
|
||||
@ -499,13 +492,7 @@ namespace Aurora::Async
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!worker)
|
||||
{
|
||||
SysPushErrorArg("invalid worker");
|
||||
return {};
|
||||
}
|
||||
|
||||
return AuMakeSharedThrow<FuncWorker>(GetWorkerInternal(worker.pool).get(), worker, AuMove(func));
|
||||
return AuMakeSharedThrow<FuncWorker>(ToInternal(worker.pool).get(), worker, AuMove(func));
|
||||
}
|
||||
|
||||
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerPId_t &worker, const AuSPtr<IWorkItemHandler> &task)
|
||||
@ -518,18 +505,14 @@ namespace Aurora::Async
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!worker)
|
||||
{
|
||||
SysPushErrorArg("invalid worker");
|
||||
return {};
|
||||
}
|
||||
|
||||
return AuMakeSharedThrow<WorkItem>(GetWorkerInternal(worker.pool).get(), worker, task);
|
||||
return AuMakeSharedThrow<WorkItem>(ToInternal(worker.pool).get(), worker, task);
|
||||
}
|
||||
|
||||
AUKN_SYM AuSPtr<IWorkItem> NewFence()
|
||||
{
|
||||
return AuMakeShared<WorkItem>(GetWorkerInternal(), AuAsync::GetCurrentWorkerPId(), AuSPtr<IWorkItemHandler>{});
|
||||
auto pWorker = GetCurrentWorkerPId().pool;
|
||||
if (!pWorker) AuUnsafeRaiiToShared(gAsyncApp);
|
||||
return AuMakeShared<WorkItem>((IThreadPoolInternal *)ToInternal(pWorker).get(), WorkerPId_t {}, AuSPtr<IWorkItemHandler>{});
|
||||
}
|
||||
|
||||
void *WorkItem::GetPrivateData()
|
||||
|
Loading…
Reference in New Issue
Block a user