summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-10-03 15:38:11 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-03 16:42:34 +0200
commitbbfde63f79b62080ade37051fc11a61ca132184f (patch)
treeb135f4de3ab23061705e6470adb159651e96831b /Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp
parent6283c098ad16a7005fac53b6c1c983dbbd3776a9 (diff)
downloadserenity-bbfde63f79b62080ade37051fc11a61ca132184f.zip
LibWeb: Only take runnable tasks from the HTML task queue
We were previously willing to execute tasks before they had become runnable.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp')
-rw-r--r--Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp
index 50c8598d67..51fb07df29 100644
--- a/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp
+++ b/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp
@@ -20,8 +20,17 @@ TaskQueue::~TaskQueue()
void TaskQueue::add(NonnullOwnPtr<Task> task)
{
- m_tasks.enqueue(move(task));
+ m_tasks.append(move(task));
m_event_loop.schedule();
}
+OwnPtr<Task> TaskQueue::take_first_runnable()
+{
+ for (size_t i = 0; i < m_tasks.size(); ++i) {
+ if (m_tasks[i]->is_runnable())
+ return m_tasks.take(i);
+ }
+ return nullptr;
+}
+
}