[+] Added AuAsync per thread io group singleton
[*] Move static functions out of the thread pool interface. no idea how i had successful builds before
This commit is contained in:
parent
2b2f5c3d23
commit
d803f1547c
@ -61,6 +61,11 @@ namespace Aurora::Async
|
||||
AUKN_SYM AuSPtr<IThreadPool> NewThreadPool();
|
||||
|
||||
AUKN_SYM void SetMainThreadForSysPumpScheduling(WorkerPId_t pid);
|
||||
|
||||
AUKN_SYM AuSPtr<IO::IIOProcessor> GetSelfIOProcessor();
|
||||
AUKN_SYM AuSPtr<IO::Net::INetInterface> GetSelfIONetInterface();
|
||||
AUKN_SYM AuSPtr<IO::Net::INetWorker> GetSelfIONetWorker();
|
||||
AUKN_SYM AuSPtr<IO::CompletionGroup::ICompletionGroup> GetSelfIOGroup();
|
||||
}
|
||||
|
||||
#if !defined(_CPPSHARP)
|
||||
|
@ -19,6 +19,11 @@ namespace Aurora::IO::Net
|
||||
struct INetWorker;
|
||||
}
|
||||
|
||||
namespace Aurora::IO::CompletionGroup
|
||||
{
|
||||
struct ICompletionGroup;
|
||||
}
|
||||
|
||||
namespace Aurora::Async
|
||||
{
|
||||
struct IThreadPool
|
||||
@ -87,10 +92,7 @@ namespace Aurora::Async
|
||||
virtual AuSPtr<IO::IIOProcessor> GetIOProcessor(WorkerId_t id) = 0;
|
||||
virtual AuSPtr<IO::Net::INetInterface> GetIONetInterface(WorkerId_t id) = 0;
|
||||
virtual AuSPtr<IO::Net::INetWorker> GetIONetWorker(WorkerId_t id) = 0;
|
||||
|
||||
static AuSPtr<IO::IIOProcessor> GetSelfIOProcessor();
|
||||
static AuSPtr<IO::Net::INetInterface> GetSelfIONetInterface();
|
||||
static AuSPtr<IO::Net::INetWorker> GetSelfIONetWorker();
|
||||
virtual AuSPtr<IO::CompletionGroup::ICompletionGroup> GetIOGroup(WorkerId_t id) = 0;
|
||||
|
||||
// Synchronization
|
||||
|
||||
|
@ -17,6 +17,11 @@ namespace Aurora::IO::CompletionGroup
|
||||
struct ICompletionGroup;
|
||||
}
|
||||
|
||||
namespace Aurora::Async
|
||||
{
|
||||
AUKN_SYM AuSPtr<IO::CompletionGroup::ICompletionGroup> GetSelfIOGroup();
|
||||
}
|
||||
|
||||
#include "CompletionGroup/ICompletionGroupWorkHandle.hpp"
|
||||
#include <Aurora/Debug/Debug.hpp>
|
||||
|
||||
@ -132,6 +137,10 @@ namespace Aurora::IO
|
||||
{
|
||||
(void)pTransaction->TryAttachToCompletionGroup(pCompletionGroup.Value());
|
||||
}
|
||||
else if (auto pGroup = Aurora::Async::GetSelfIOGroup())
|
||||
{
|
||||
(void)pTransaction->TryAttachToCompletionGroup(pGroup);
|
||||
}
|
||||
|
||||
if (callback)
|
||||
{
|
||||
@ -157,6 +166,10 @@ namespace Aurora::IO
|
||||
{
|
||||
(void)pTransaction->TryAttachToCompletionGroup(pCompletionGroup.Value());
|
||||
}
|
||||
else if (auto pGroup = Aurora::Async::GetSelfIOGroup())
|
||||
{
|
||||
(void)pTransaction->TryAttachToCompletionGroup(pGroup);
|
||||
}
|
||||
|
||||
if (callback)
|
||||
{
|
||||
|
@ -23,4 +23,56 @@ namespace Aurora::Async
|
||||
DeinitSched();
|
||||
ReleaseApp();
|
||||
}
|
||||
|
||||
AuSPtr<IO::IIOProcessor> GetSelfIOProcessor()
|
||||
{
|
||||
auto pid = GetCurrentWorkerPId();
|
||||
if (pid)
|
||||
{
|
||||
return pid.GetPool()->GetIOProcessor(pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
AuSPtr<IO::Net::INetInterface> GetSelfIONetInterface()
|
||||
{
|
||||
auto pid = GetCurrentWorkerPId();
|
||||
if (pid)
|
||||
{
|
||||
return pid.GetPool()->GetIONetInterface(pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
AuSPtr<IO::Net::INetWorker> GetSelfIONetWorker()
|
||||
{
|
||||
auto pid = GetCurrentWorkerPId();
|
||||
if (pid)
|
||||
{
|
||||
return pid.GetPool()->GetIONetWorker(pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
AuSPtr<IO::CompletionGroup::ICompletionGroup> GetSelfIOGroup()
|
||||
{
|
||||
auto pid = GetCurrentWorkerPId();
|
||||
if (pid)
|
||||
{
|
||||
return pid.GetPool()->GetIOGroup(pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
@ -248,6 +248,11 @@ namespace Aurora::Async
|
||||
return ThreadPool::GetIONetWorker(pid);
|
||||
}
|
||||
|
||||
AuSPtr<IO::CompletionGroup::ICompletionGroup> AsyncApp::GetIOGroup(WorkerId_t pid)
|
||||
{
|
||||
return ThreadPool::GetIOGroup(pid);
|
||||
}
|
||||
|
||||
AuSPtr<AuLoop::ILoopQueue> AsyncApp::ToKernelWorkQueue()
|
||||
{
|
||||
return ThreadPool::ToKernelWorkQueue();
|
||||
|
@ -48,6 +48,7 @@ namespace Aurora::Async
|
||||
AuSPtr<AuIO::Net::INetWorker> GetIONetWorker(WorkerId_t pid) override;
|
||||
AuSPtr<AuLoop::ILoopQueue> ToKernelWorkQueue() override;
|
||||
AuSPtr<AuLoop::ILoopQueue> ToKernelWorkQueue(WorkerId_t workerId) override;
|
||||
AuSPtr<IO::CompletionGroup::ICompletionGroup> GetIOGroup(WorkerId_t id) override;
|
||||
|
||||
// Main thread logic
|
||||
void Start() override;
|
||||
|
@ -29,6 +29,25 @@ namespace Aurora::Async
|
||||
}
|
||||
}
|
||||
|
||||
AuSPtr<AuIO::CompletionGroup::ICompletionGroup> ThreadStateSingletons::GetIOGroup()
|
||||
{
|
||||
if (this->pGroup)
|
||||
{
|
||||
return this->pGroup;
|
||||
}
|
||||
|
||||
{
|
||||
AU_LOCK_GUARD(this->mutex);
|
||||
|
||||
if (this->pGroup)
|
||||
{
|
||||
return this->pGroup;
|
||||
}
|
||||
|
||||
return this->pGroup = AuIO::CompletionGroup::NewCompletionGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadStateSingletons::TryInitNet(AuWorkerPId_t pid)
|
||||
{
|
||||
if (this->pNetInterface)
|
||||
|
@ -20,7 +20,9 @@ namespace Aurora::Async
|
||||
AuSPtr<AuIO::IIOProcessor> pIOProcessor;
|
||||
AuSPtr<AuIO::Net::INetInterface> pNetInterface;
|
||||
AuSPtr<AuIO::Net::INetWorker> pNetWorker;
|
||||
AuSPtr<AuIO::CompletionGroup::ICompletionGroup> pGroup;
|
||||
|
||||
AuSPtr<AuIO::CompletionGroup::ICompletionGroup> GetIOGroup();
|
||||
AuSPtr<AuIO::IIOProcessor> GetIOProcessor(AuWorkerPId_t pid);
|
||||
AuSPtr<AuIO::Net::INetInterface> GetIONetInterface(AuWorkerPId_t pid);
|
||||
AuSPtr<AuIO::Net::INetWorker> GetIONetWorker(AuWorkerPId_t pid);
|
||||
|
@ -811,6 +811,16 @@ namespace Aurora::Async
|
||||
return {};
|
||||
}
|
||||
|
||||
AuSPtr<IO::CompletionGroup::ICompletionGroup> ThreadPool::GetIOGroup(WorkerId_t id)
|
||||
{
|
||||
if (auto pState = this->GetThreadHandle(id))
|
||||
{
|
||||
return pState->singletons.GetIOGroup();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
AuSPtr<AuIO::Net::INetInterface> ThreadPool::GetIONetInterface(WorkerId_t pid)
|
||||
{
|
||||
if (auto pState = this->GetThreadHandle(pid))
|
||||
@ -830,45 +840,6 @@ namespace Aurora::Async
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
AuSPtr<IO::IIOProcessor> ThreadPool::GetSelfIOProcessor()
|
||||
{
|
||||
auto pid = GetCurrentWorkerPId();
|
||||
if (pid)
|
||||
{
|
||||
return pid.GetPool()->GetIOProcessor(pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
AuSPtr<IO::Net::INetInterface> ThreadPool::GetSelfIONetInterface()
|
||||
{
|
||||
auto pid = GetCurrentWorkerPId();
|
||||
if (pid)
|
||||
{
|
||||
return pid.GetPool()->GetIONetInterface(pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
AuSPtr<IO::Net::INetWorker> ThreadPool::GetSelfIONetWorker()
|
||||
{
|
||||
auto pid = GetCurrentWorkerPId();
|
||||
if (pid)
|
||||
{
|
||||
return pid.GetPool()->GetIONetWorker(pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
bool ThreadPool::Sync(WorkerId_t workerId, AuUInt32 timeoutMs, bool requireSignal)
|
||||
{
|
||||
|
@ -63,10 +63,7 @@ namespace Aurora::Async
|
||||
virtual AuSPtr<AuIO::IIOProcessor> GetIOProcessor(WorkerId_t id) override;
|
||||
virtual AuSPtr<AuIO::Net::INetInterface> GetIONetInterface(WorkerId_t pid) override;
|
||||
virtual AuSPtr<AuIO::Net::INetWorker> GetIONetWorker(WorkerId_t id) override;
|
||||
|
||||
AuSPtr<IO::IIOProcessor> GetSelfIOProcessor();
|
||||
AuSPtr<IO::Net::INetInterface> GetSelfIONetInterface();
|
||||
AuSPtr<IO::Net::INetWorker> GetSelfIONetWorker();
|
||||
virtual AuSPtr<AuIO::CompletionGroup::ICompletionGroup> GetIOGroup(WorkerId_t id) override;
|
||||
|
||||
virtual bool Sync(WorkerId_t workerId, AuUInt32 timeoutMs, bool requireSignal) override;
|
||||
virtual void Signal(WorkerId_t workerId) override;
|
||||
|
Loading…
Reference in New Issue
Block a user