mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb: Support taking matching tasks out of a task queue
This will be needed for HTMLMediaElement.
This commit is contained in:
parent
807891c0df
commit
9a370a5eed
Notes:
sideshowbarker
2024-07-17 12:02:22 +09:00
Author: https://github.com/trflynn89
Commit: 9a370a5eed
Pull-request: https://github.com/SerenityOS/serenity/pull/18183
Reviewed-by: https://github.com/Lubrsi
Reviewed-by: https://github.com/linusg ✅
Reviewed-by: https://github.com/skyrising
2 changed files with 19 additions and 0 deletions
|
@ -53,4 +53,22 @@ void TaskQueue::remove_tasks_matching(Function<bool(HTML::Task const&)> filter)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<Vector<NonnullOwnPtr<Task>>> TaskQueue::take_tasks_matching(Function<bool(HTML::Task const&)> filter)
|
||||||
|
{
|
||||||
|
Vector<NonnullOwnPtr<Task>> matching_tasks;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < m_tasks.size();) {
|
||||||
|
auto& task = m_tasks.at(i);
|
||||||
|
|
||||||
|
if (filter(*task)) {
|
||||||
|
TRY(matching_tasks.try_append(move(task)));
|
||||||
|
m_tasks.remove(i);
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return matching_tasks;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_tasks_matching(Function<bool(HTML::Task const&)>);
|
void remove_tasks_matching(Function<bool(HTML::Task const&)>);
|
||||||
|
ErrorOr<Vector<NonnullOwnPtr<Task>>> take_tasks_matching(Function<bool(HTML::Task const&)>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTML::EventLoop& m_event_loop;
|
HTML::EventLoop& m_event_loop;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue