LibCore: Allow posting stateless events without heap-allocated Event

This patch adds an API for posting a Core::Event::Type to the thread
event queue without requiring a full Core::Event object.

We use this API to avoid heap allocations for every timer and notifier
activation event.
This commit is contained in:
Andreas Kling 2025-12-03 11:38:19 +01:00 committed by Andreas Kling
parent 23fb9781d1
commit 69515f8c85
Notes: github-actions[bot] 2025-12-03 12:27:51 +00:00
5 changed files with 48 additions and 15 deletions

View file

@ -196,7 +196,7 @@ size_t EventLoopImplementationWindows::pump(PumpMode pump_mode)
if (packet->type == CompletionType::Timer) {
auto* timer = static_cast<EventLoopTimer*>(packet);
if (auto owner = timer->owner.strong_ref())
event_queue.post_event(owner, make<TimerEvent>());
event_queue.post_event(owner, Event::Type::Timer);
if (timer->is_periodic) {
NTSTATUS status = g_system.NtAssociateWaitCompletionPacket(timer->wait_packet.handle, thread_data->iocp.handle, timer->timer.handle, timer, NULL, 0, 0, NULL);
VERIFY(NT_SUCCESS(status));
@ -205,7 +205,7 @@ size_t EventLoopImplementationWindows::pump(PumpMode pump_mode)
}
if (packet->type == CompletionType::Notifer) {
auto* notifier_data = static_cast<EventLoopNotifier*>(packet);
event_queue.post_event(notifier_data->notifier, make<NotifierActivationEvent>());
event_queue.post_event(notifier_data->notifier, Core::Event::Type::NotifierActivation);
NTSTATUS status = g_system.NtAssociateWaitCompletionPacket(notifier_data->wait_packet.handle, thread_data->iocp.handle, notifier_data->wait_event.handle, notifier_data, NULL, 0, 0, NULL);
VERIFY(NT_SUCCESS(status));
continue;