1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

LibWeb: Use Core::EventLoop::spin_until() for the ad-hoc loop spinning

The ideal solution here is to implement a more spec-compliant event
loop, but while we get all the pieces in place for that, this at least
makes the HTML event loop a bit more responsive since it never has to
wait for a 16ms timer to fire.
This commit is contained in:
Andreas Kling 2021-09-25 19:33:13 +02:00
parent f2b9ec9f8a
commit 926a49cd81

View file

@ -45,18 +45,11 @@ EventLoop& main_thread_event_loop()
}
// https://html.spec.whatwg.org/multipage/webappapis.html#spin-the-event-loop
void EventLoop::spin_until([[maybe_unused]] Function<bool()> goal_condition)
void EventLoop::spin_until(Function<bool()> goal_condition)
{
// FIXME: This is an ad-hoc hack until we implement the proper mechanism.
if (goal_condition())
return;
Core::EventLoop loop;
auto timer = Core::Timer::create_repeating(16, [&] {
if (goal_condition())
loop.quit(0);
});
timer->start();
loop.exec();
loop.spin_until(move(goal_condition));
// Real spec steps: