mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 20:17:13 +02: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:
Notes:
sideshowbarker
2024-07-18 04:24:27 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/909e522cf70
@@ -13,7 +13,7 @@ namespace Web::HTML {
|
||||
|
||||
class TaskQueue {
|
||||
public:
|
||||
TaskQueue();
|
||||
explicit TaskQueue(HTML::EventLoop&);
|
||||
~TaskQueue();
|
||||
|
||||
bool is_empty() const { return m_tasks.is_empty(); }
|
||||
@@ -22,6 +22,8 @@ public:
|
||||
OwnPtr<HTML::Task> take_first_runnable() { return m_tasks.dequeue(); }
|
||||
|
||||
private:
|
||||
HTML::EventLoop& m_event_loop;
|
||||
|
||||
Queue<NonnullOwnPtr<HTML::Task>> m_tasks;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user