mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 20:15:07 +00:00
LibWeb: Only take runnable tasks from the HTML task queue
We were previously willing to execute tasks before they had become runnable.
This commit is contained in:
parent
6283c098ad
commit
bbfde63f79
5 changed files with 23 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue