[+] IOConfig::bAPCUseCoroutineStack

This commit is contained in:
Reece Wilson 2024-09-09 08:16:19 +01:00
parent 89686eb022
commit 634eb35959
7 changed files with 126 additions and 5 deletions

View File

@ -279,6 +279,9 @@ namespace Aurora
//
bool bUseHighResTimerUnderIOWaitableTimer { false };
//
bool bAPCUseCoroutineStack { true };
};
struct Win32Config

View File

@ -465,7 +465,48 @@ namespace Aurora::IO::FS
if (this->pSub_)
{
this->pSub_->OnAsyncFileOpFinished(this->qwLastAbstractOffset, read);
this->RoutineCallCB(read);
}
}
#if defined(__AUHAS_COROUTINES_CO_AWAIT) && defined(AU_LANG_CPP_20_)
AuVoidTask NtAsyncFileTransaction::RoutineCallCB_(AuUInt32 len)
{
if (this->pSub_)
{
try
{
this->pSub_->OnAsyncFileOpFinished(this->qwLastAbstractOffset, len);
}
catch (...)
{
SysPushErrorCatch();
}
}
co_return;
}
#endif
void NtAsyncFileTransaction::RoutineCallCB(AuUInt32 len)
{
#if defined(__AUHAS_COROUTINES_CO_AWAIT) && defined(AU_LANG_CPP_20_)
if (gRuntimeConfig.ioConfig.bAPCUseCoroutineStack)
{
this->RoutineCallCB_(len);
return;
}
#endif
if (this->pSub_)
{
try
{
this->pSub_->OnAsyncFileOpFinished(this->qwLastAbstractOffset, len);
}
catch (...)
{
SysPushErrorCatch();
}
}
}

View File

@ -77,6 +77,12 @@ namespace Aurora::IO::FS
bool IDontWannaUsePorts();
void DispatchCb(AuUInt32 len);
void RoutineCallCB(AuUInt32 len);
#if defined(__AUHAS_COROUTINES_CO_AWAIT) && defined(AU_LANG_CPP_20_)
AuVoidTask RoutineCallCB_(AuUInt32 len);
#endif
HANDLE GetHandle();
AuSPtr<IIOHandle> GetFileHandle();

View File

@ -555,17 +555,45 @@ namespace Aurora::IO::Net
return;
}
if (this->pSub)
{
this->RoutineCallCB(read);
}
}
#if defined(__AUHAS_COROUTINES_CO_AWAIT) && defined(AU_LANG_CPP_20_)
AuVoidTask NtAsyncNetworkTransaction::RoutineCallCB_(AuUInt32 len)
{
if (this->pSub)
{
try
{
this->pSub->OnAsyncFileOpFinished(this->dwLastAbstractOffset, read);
this->pSub->OnAsyncFileOpFinished(this->dwLastAbstractOffset, len);
}
catch (...)
{
SysPushErrorCatch();
}
}
co_return;
}
#endif
void NtAsyncNetworkTransaction::RoutineCallCB(AuUInt32 len)
{
#if defined(__AUHAS_COROUTINES_CO_AWAIT) && defined(AU_LANG_CPP_20_)
if (gRuntimeConfig.ioConfig.bAPCUseCoroutineStack)
{
this->RoutineCallCB_(len);
return;
}
#endif
if (this->pSub)
{
this->pSub->OnAsyncFileOpFinished(this->dwLastAbstractOffset, len);
}
}
SOCKET NtAsyncNetworkTransaction::GetSocket()

View File

@ -54,6 +54,10 @@ namespace Aurora::IO::Net
bool IDontWannaUsePorts();
void DispatchCb(AuUInt32 len);
void RoutineCallCB(AuUInt32 len);
#if defined(__AUHAS_COROUTINES_CO_AWAIT) && defined(AU_LANG_CPP_20_)
AuVoidTask RoutineCallCB_(AuUInt32 len);
#endif
SOCKET GetSocket();
HANDLE GetAlertable();

View File

@ -43,6 +43,40 @@ namespace Aurora::IO::UNIX
}
}
void ASubmittable::LIOS_ProcessStack(AuUInt32 read, bool failure, int err, bool mark)
{
#if defined(__AUHAS_COROUTINES_CO_AWAIT) && defined(AU_LANG_CPP_20_)
if (gRuntimeConfig.ioConfig.bAPCUseCoroutineStack)
{
this->LIOS_ProcessStack_(read, failure, err, mark);
return;
}
#endif
try
{
this->LIOS_Process(read, failure, err, mark);
}
catch (...)
{
SysPushErrorCatch("IO Callback threw an exception");
}
}
#if defined(__AUHAS_COROUTINES_CO_AWAIT) && defined(AU_LANG_CPP_20_)
AuVoidTask ASubmittable::LIOS_ProcessStack_(AuUInt32 read, bool failure, int err, bool mark)
{
try
{
this->LIOS_Process(read, failure, err, mark);
}
catch (...)
{
SysPushErrorCatch("IO Callback threw an exception");
}
}
#endif
void ASubmittable::LIOS_SendProcess(AuUInt32 read, bool failure, int err, bool mark)
{
// Allow for reuse by releasing before dispatch
@ -63,7 +97,7 @@ namespace Aurora::IO::UNIX
{
try
{
LIOS_Process(0, true, 69, false);
LIOS_ProcessStack(0, true, 69, false);
}
catch (...)
{
@ -82,7 +116,7 @@ namespace Aurora::IO::UNIX
try
{
LIOS_Process(read, failure, err, mark);
LIOS_ProcessStack(read, failure, err, mark);
}
catch (...)
{

View File

@ -26,6 +26,11 @@ namespace Aurora::IO::UNIX
bool LIOS_Cancel();
bool HasState();
void LIOS_ProcessStack(AuUInt32 read, bool failure, int err, bool mark);
#if defined(__AUHAS_COROUTINES_CO_AWAIT) && defined(AU_LANG_CPP_20_)
AuVoidTask LIOS_ProcessStack_(AuUInt32 read, bool failure, int err, bool mark);
#endif
void SetMemory(const AuMemoryViewRead &view);
void SetMemory(const AuMemoryViewWrite &view);