LibCore: Add Core::EventLoop::spin_until(Function<bool()>)

This function spins the event loop until a goal condition is met.
This commit is contained in:
Andreas Kling 2021-09-25 19:32:14 +02:00
commit f2b9ec9f8a
Notes: sideshowbarker 2024-07-18 03:27:35 +09:00
2 changed files with 9 additions and 0 deletions

View file

@ -366,6 +366,13 @@ int EventLoop::exec()
VERIFY_NOT_REACHED();
}
void EventLoop::spin_until(Function<bool()> goal_condition)
{
EventLoopPusher pusher(*this);
while (!goal_condition())
pump();
}
void EventLoop::pump(WaitMode mode)
{
wait_for_event(mode);