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

LibWeb: Schedule HTML::EventLoop processing when there are queued tasks

Since we can't simply give HTML::EventLoop control of the whole program,
we have to integrate with Core::EventLoop.

We do this by having a single-shot 0ms Core::Timer that we start when
a task is added to the queue, and restart after processing the queue and
there are still tasks in the queue.
This commit is contained in:
Andreas Kling 2021-09-09 00:38:43 +02:00
parent e0c7f8dafa
commit 909e522cf7
5 changed files with 35 additions and 2 deletions

View file

@ -7,6 +7,8 @@
#pragma once
#include <AK/Function.h>
#include <LibCore/Forward.h>
#include <LibJS/Forward.h>
#include <LibWeb/HTML/EventLoop/TaskQueue.h>
namespace Web::HTML {
@ -40,6 +42,8 @@ public:
void set_vm(JS::VM&);
void schedule();
private:
Type m_type { Type::Window };
@ -49,6 +53,8 @@ private:
Task* m_currently_running_task { nullptr };
JS::VM* m_vm { nullptr };
RefPtr<Core::Timer> m_system_event_loop_timer;
};
EventLoop& main_thread_event_loop();