LibCore: Tighten EventLoop current-loop checks

Make EventLoop::current() enforce the presence of a current event loop
directly, and make EventLoop::pump() verify that it is pumping the
current thread event loop. This keeps the one-loop-per-thread invariant
explicit across the public EventLoop entry points.
This commit is contained in:
Andreas Kling 2026-06-04 20:25:07 +02:00 committed by Andreas Kling
parent 789d7cba48
commit ab5709edfd

View file

@ -54,8 +54,7 @@ bool EventLoop::is_running()
EventLoop& EventLoop::current()
{
if (!current_event_loop())
dbgln("No EventLoop is present, unable to return current one!");
VERIFY(current_event_loop());
return *current_event_loop();
}
@ -92,6 +91,7 @@ void EventLoop::spin_until(Function<bool()> goal_condition)
size_t EventLoop::pump(WaitMode mode)
{
VERIFY(current_event_loop() == this);
return m_impl->pump(mode == WaitMode::WaitForEvents ? EventLoopImplementation::PumpMode::WaitForEvents : EventLoopImplementation::PumpMode::DontWaitForEvents);
}