[+] NT: Let Grug handle io handle closures
This commit is contained in:
parent
a3046658fe
commit
e7d8e5b010
@ -31,9 +31,11 @@ namespace Aurora::Grug
|
||||
static const auto kGrugFlushMs = 500;
|
||||
|
||||
static AuThreads::ThreadUnique_t gGrugsBigWorld;
|
||||
static AuThreadPrimitives::ConditionMutex gMutex; // ^ that
|
||||
static AuThreadPrimitives::ConditionVariable gCondVar(AuUnsafeRaiiToShared(gMutex.AsPointer())); // slow logger work queue
|
||||
static AuThreadPrimitives::Semaphore gArrows;
|
||||
static AuCondMutex gMutex; // ^ that
|
||||
static AuConditionVariable gCondVar(AuUnsafeRaiiToShared(gMutex.AsPointer())); // slow logger work queue
|
||||
static AuSemaphore gArrows;
|
||||
static AuMutex gOtherMutex;
|
||||
static AuList<AuUInt> gHandlesToClose;
|
||||
|
||||
static void SlowStartupTasks()
|
||||
{
|
||||
@ -100,6 +102,7 @@ namespace Aurora::Grug
|
||||
::LinuxSuperSecretIOTick();
|
||||
#endif
|
||||
|
||||
GrugDoIoWork();
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,10 +192,41 @@ namespace Aurora::Grug
|
||||
Logging::ForceFlushLoggers();
|
||||
}
|
||||
|
||||
void GrugDoIoWork()
|
||||
{
|
||||
if (gHandlesToClose.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AU_LOCK_GUARD(gOtherMutex);
|
||||
for (const auto uHandle : AuExchange(gHandlesToClose, {}))
|
||||
{
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
auto pHandle = (void *)uHandle;
|
||||
AuWin32CloseHandle(pHandle);
|
||||
#elif defined(AURORA_IS_POSIX_DERIVED)
|
||||
close(uHandle);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void GrugFlushFlushs()
|
||||
{
|
||||
Logging::ForceFlushFlush();
|
||||
Console::PumpOffMain();
|
||||
Console::ForceFlush();
|
||||
GrugDoIoWork();
|
||||
}
|
||||
|
||||
void CloseHandle(AuUInt64 handle)
|
||||
{
|
||||
{
|
||||
AU_DEBUG_MEMCRUNCH;
|
||||
AU_LOCK_GUARD(gOtherMutex);
|
||||
gHandlesToClose.push_back(handle);
|
||||
}
|
||||
|
||||
NotifyGrugOfTelemetry();
|
||||
}
|
||||
}
|
@ -16,10 +16,13 @@ namespace Aurora::Grug
|
||||
void GrugFlushFlushs();
|
||||
void NotifyGrugOfLogs();
|
||||
void NotifyGrugOfTelemetry();
|
||||
void GrugDoIoWork();
|
||||
|
||||
void DrachenlordScreech();
|
||||
bool IsGrug();
|
||||
|
||||
void InitGrug();
|
||||
void DeinitGrug();
|
||||
|
||||
void CloseHandle(AuUInt64 handle);
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "FS/FS.hpp"
|
||||
#include "FS/FileAdvisory.NT.hpp"
|
||||
#include <Source/Grug/AuGrug.hpp>
|
||||
|
||||
namespace Aurora::IO
|
||||
{
|
||||
@ -41,8 +42,12 @@ namespace Aurora::IO
|
||||
|
||||
void AFileHandle::CloseHandle(AuUInt64 uOSHandle)
|
||||
{
|
||||
#if 0
|
||||
HANDLE hHandle = (HANDLE)uOSHandle;
|
||||
AuWin32CloseHandle(hHandle);
|
||||
#else
|
||||
Grug::CloseHandle(uOSHandle);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AFileHandle::InitStdIn(bool bSharing)
|
||||
|
Loading…
Reference in New Issue
Block a user