From d910c71ad8694d9494e47a65ab058e796227bffb Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Sat, 21 Oct 2023 06:25:25 +0100 Subject: [PATCH] [*] This snucked in and i forgot to enable an nt specific fast path --- Source/IO/Loop/Loop.cpp | 43 ++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/Source/IO/Loop/Loop.cpp b/Source/IO/Loop/Loop.cpp index c1c770dd..b61b395c 100644 --- a/Source/IO/Loop/Loop.cpp +++ b/Source/IO/Loop/Loop.cpp @@ -51,7 +51,7 @@ namespace Aurora::IO::Loop return workerPid.pool->WorkerToLoopSource(workerPid); } -#if defined(AURORA_PLATFORM_WIN32) +#if defined(AURORA_IS_MODERNNT_DERIVED) AuList> WaitMultipleOrObjects(const AuList> &objects, AuUInt32 timeout); #endif AuList> WaitMultipleOrObjectsFallback(const AuList> &objects, AuUInt32 timeout, bool &bTimeout); @@ -110,7 +110,6 @@ namespace Aurora::IO::Loop if (!bAny) { - AuSPtr pQueue; auto &entryZero = lsList[0]; if (!entryZero) @@ -133,12 +132,6 @@ namespace Aurora::IO::Loop if (lsList.size() > 1) { - pQueue = AuLoop::NewLoopQueue(); - if (!pQueue) - { - goto next; - } - for (AU_ITERATE_N_TO_X(i, 1, lsList.size())) { AuUInt32 uTimeoutMS {}; @@ -186,15 +179,47 @@ namespace Aurora::IO::Loop } else { + auto start = lsList.begin(); + + auto type = lsList[0]; + if (type->GetType() == ELoopSource::eSourceMutex || + type->GetType() == ELoopSource::eSourceSemaphore) + { + for (AU_ITERATE_N(i, lsList.size())) + { + if (!lsList[i]->IsSignaled()) + { + break; + } + + start++; + } + } + + AuList> next(start, lsList.end()); bool bTimeout {}; - signaled = WaitMultipleOrObjectsFallback(lsList, uTimeoutMS, bTimeout); + + #if defined(AURORA_IS_MODERNNT_DERIVED) + signaled = WaitMultipleOrObjects(next, uTimeoutMS); + bTimeout = bTimeout ? + Time::SteadyClockNS() >= uTimeoutEnd : + false; + #else + signaled = WaitMultipleOrObjectsFallback(next, uTimeoutMS, bTimeout); + #endif + + signaled.insert(signaled.end(), lsList.begin(), start); if (bTimeout) { return false; } + #if 0 return true; + #else + return signaled.size(); + #endif } }