
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
If, by the time we need to schedule rendering of the next frame, the previous one is still not processed, we could skip it instead of growing task queue. Should help with https://github.com/LadybirdBrowser/ladybird/issues/1647
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2021-2024, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Queue.h>
|
|
#include <LibJS/Heap/Cell.h>
|
|
#include <LibWeb/HTML/EventLoop/Task.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
class TaskQueue : public JS::Cell {
|
|
JS_CELL(TaskQueue, JS::Cell);
|
|
JS_DECLARE_ALLOCATOR(TaskQueue);
|
|
|
|
public:
|
|
explicit TaskQueue(HTML::EventLoop&);
|
|
virtual ~TaskQueue() override;
|
|
|
|
bool is_empty() const { return m_tasks.is_empty(); }
|
|
|
|
bool has_runnable_tasks() const;
|
|
bool has_rendering_tasks() const;
|
|
|
|
void add(JS::NonnullGCPtr<HTML::Task>);
|
|
JS::GCPtr<HTML::Task> take_first_runnable();
|
|
|
|
void enqueue(JS::NonnullGCPtr<HTML::Task> task) { add(task); }
|
|
JS::GCPtr<HTML::Task> dequeue()
|
|
{
|
|
if (m_tasks.is_empty())
|
|
return {};
|
|
return m_tasks.take_first();
|
|
}
|
|
|
|
void remove_tasks_matching(Function<bool(HTML::Task const&)>);
|
|
JS::MarkedVector<JS::NonnullGCPtr<Task>> take_tasks_matching(Function<bool(HTML::Task const&)>);
|
|
|
|
Task const* last_added_task() const;
|
|
|
|
private:
|
|
virtual void visit_edges(Visitor&) override;
|
|
|
|
JS::NonnullGCPtr<HTML::EventLoop> m_event_loop;
|
|
|
|
Vector<JS::NonnullGCPtr<HTML::Task>> m_tasks;
|
|
};
|
|
|
|
}
|