From ee4d944340aa6204d473f882c4d14b9a49b7a5b8 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 6 Oct 2025 09:09:34 +0000 Subject: [PATCH] [windows] Use condvar wait to reduce sched contention Signed-off-by: lizzie --- src/core/core_timing.cpp | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 1c0a2d7bca..8725c0397f 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -288,28 +288,8 @@ void CoreTiming::ThreadLoop() { const auto next_time = Advance(); if (next_time) { // There are more events left in the queue, wait until the next event. - auto wait_time = *next_time - GetGlobalTimeNs().count(); - if (wait_time > 0) { -#ifdef _WIN32 - while (!paused && !event.IsSet() && wait_time > 0) { - wait_time = *next_time - GetGlobalTimeNs().count(); - if (wait_time >= timer_resolution_ns) { - Common::Windows::SleepForOneTick(); - } else { -#ifdef ARCHITECTURE_x86_64 - Common::X64::MicroSleep(); -#else - std::this_thread::yield(); -#endif - } - } - - if (event.IsSet()) { - event.Reset(); - } -#else + if (auto wait_time = *next_time - GetGlobalTimeNs().count(); wait_time > 0) { event.WaitFor(std::chrono::nanoseconds(wait_time)); -#endif } } else { // Queue is empty, wait until another event is scheduled and signals us to -- 2.39.5