mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +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:
parent
e0c7f8dafa
commit
909e522cf7
Notes:
sideshowbarker
2024-07-18 04:24:27 +09:00
Author: https://github.com/awesomekling
Commit: 909e522cf7
5 changed files with 35 additions and 2 deletions
|
@ -4,11 +4,13 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/HTML/EventLoop/TaskQueue.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
TaskQueue::TaskQueue()
|
||||
TaskQueue::TaskQueue(HTML::EventLoop& event_loop)
|
||||
: m_event_loop(event_loop)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -19,6 +21,7 @@ TaskQueue::~TaskQueue()
|
|||
void TaskQueue::add(NonnullOwnPtr<Task> task)
|
||||
{
|
||||
m_tasks.enqueue(move(task));
|
||||
m_event_loop.schedule();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue