[+] 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 bUseHighResTimerUnderIOWaitableTimer { false };
//
bool bAPCUseCoroutineStack { true };
}; };
struct Win32Config struct Win32Config

View File

@ -465,7 +465,48 @@ namespace Aurora::IO::FS
if (this->pSub_) 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(); bool IDontWannaUsePorts();
void DispatchCb(AuUInt32 len); 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(); HANDLE GetHandle();
AuSPtr<IIOHandle> GetFileHandle(); AuSPtr<IIOHandle> GetFileHandle();

View File

@ -555,17 +555,45 @@ namespace Aurora::IO::Net
return; 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) if (this->pSub)
{ {
try try
{ {
this->pSub->OnAsyncFileOpFinished(this->dwLastAbstractOffset, read); this->pSub->OnAsyncFileOpFinished(this->dwLastAbstractOffset, len);
} }
catch (...) catch (...)
{ {
SysPushErrorCatch(); 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() SOCKET NtAsyncNetworkTransaction::GetSocket()

View File

@ -54,7 +54,11 @@ namespace Aurora::IO::Net
bool IDontWannaUsePorts(); bool IDontWannaUsePorts();
void DispatchCb(AuUInt32 len); 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(); SOCKET GetSocket();
HANDLE GetAlertable(); 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) void ASubmittable::LIOS_SendProcess(AuUInt32 read, bool failure, int err, bool mark)
{ {
// Allow for reuse by releasing before dispatch // Allow for reuse by releasing before dispatch
@ -63,7 +97,7 @@ namespace Aurora::IO::UNIX
{ {
try try
{ {
LIOS_Process(0, true, 69, false); LIOS_ProcessStack(0, true, 69, false);
} }
catch (...) catch (...)
{ {
@ -82,7 +116,7 @@ namespace Aurora::IO::UNIX
try try
{ {
LIOS_Process(read, failure, err, mark); LIOS_ProcessStack(read, failure, err, mark);
} }
catch (...) catch (...)
{ {

View File

@ -26,6 +26,11 @@ namespace Aurora::IO::UNIX
bool LIOS_Cancel(); bool LIOS_Cancel();
bool HasState(); 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 AuMemoryViewRead &view);
void SetMemory(const AuMemoryViewWrite &view); void SetMemory(const AuMemoryViewWrite &view);