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
This commit is contained in:
stasoid 2025-01-08 11:53:32 +05:00 committed by Andrew Kaster
parent 33457f389d
commit 5ea4d26458
Notes: github-actions[bot] 2025-04-11 01:03:21 +00:00

View file

@ -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);