LibCore: Use IOCP for the event loop on Windows

This commit changes the event loop to use IOCPs instead of
WaitForMultipleObjects to wait on events. This is done through the Nt
kernel api NtAssociateWaitCompletionPacket which associates an event
with a completion packet. Each completion packet notifies only once, as
they are normally used to signal completion of an operation so to use
them for notifiers they are associated again after each time they are
triggered.
There are more optimizations that can be done, such as reusing the
EventLoopNotifier and EventLoopTimer structures to reduce the number of
allocations and context switches for timer and notifier registration.
This commit is contained in:
R-Goc
2025-09-02 17:14:30 +02:00
committed by Jelle Raaijmakers
parent af1bf342f9
commit 86b95b1d7a
Notes: github-actions[bot] 2025-11-07 07:43:41 +00:00
6 changed files with 243 additions and 84 deletions

View File

@@ -34,7 +34,7 @@ public:
static NonnullOwnPtr<EventLoopImplementationWindows> create() { return make<EventLoopImplementationWindows>(); }
EventLoopImplementationWindows();
virtual ~EventLoopImplementationWindows() override = default;
virtual ~EventLoopImplementationWindows() override;
virtual int exec() override;
virtual size_t pump(PumpMode) override;
@@ -48,8 +48,7 @@ private:
bool m_exit_requested { false };
int m_exit_code { 0 };
// The wake event handle of this event loop needs to be accessible from other threads.
void*& m_wake_event;
void const* m_wake_completion_key;
};
using EventLoopManagerPlatform = EventLoopManagerWindows;