mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:57:44 +00:00
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:
parent
2c0987c93b
commit
f2b9ec9f8a
2 changed files with 9 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue