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:
parent
789d7cba48
commit
ab5709edfd
1 changed files with 2 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue