From 5ea4d2645800d6108fc148f41467a2954b7c2f0d Mon Sep 17 00:00:00 2001 From: stasoid Date: Wed, 8 Jan 2025 11:53:32 +0500 Subject: [PATCH] LibCore: Don't wait in WaitForMultipleObjects if thread event queue has pending events in EventLoopImplementationWindows This matches the behavior of the Linux version: https://github.com/LadybirdBrowser/ladybird/blob/911cd4aefd0c/Libraries/LibCore/EventLoopImplementationUnix.cpp#L371 --- Libraries/LibCore/EventLoopImplementationWindows.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/LibCore/EventLoopImplementationWindows.cpp b/Libraries/LibCore/EventLoopImplementationWindows.cpp index 37afaf01dba..c6274e01ea8 100644 --- a/Libraries/LibCore/EventLoopImplementationWindows.cpp +++ b/Libraries/LibCore/EventLoopImplementationWindows.cpp @@ -112,7 +112,9 @@ size_t EventLoopImplementationWindows::pump(PumpMode) for (auto& entry : timers) event_handles.append(entry.key.handle); - DWORD result = WaitForMultipleObjects(event_count, event_handles.data(), FALSE, INFINITE); + bool has_pending_events = ThreadEventQueue::current().has_pending_events(); + int timeout = has_pending_events ? 0 : INFINITE; + DWORD result = WaitForMultipleObjects(event_count, event_handles.data(), FALSE, timeout); size_t index = result - WAIT_OBJECT_0; VERIFY(index < event_count);