LibWeb: Make EventLoop, TaskQueue, and Task GC-allocated

...and use HeapFunction instead of SafeFunction for task steps.

Since there is only one EventLoop per process, it lives as a global
handle in the VM custom data.

This makes it much easier to reason about lifetimes of tasks, task
steps, and random stuff captured by them.
This commit is contained in:
Andreas Kling 2024-04-04 12:06:50 +02:00
commit 2ef37c0b06
Notes: sideshowbarker 2024-07-17 02:14:39 +09:00
20 changed files with 167 additions and 124 deletions

View file

@ -11,7 +11,7 @@
namespace Web::Fetch::Infrastructure {
// https://fetch.spec.whatwg.org/#queue-a-fetch-task
int queue_fetch_task(JS::Object& task_destination, JS::SafeFunction<void()> algorithm)
int queue_fetch_task(JS::Object& task_destination, Function<void()> algorithm)
{
// FIXME: 1. If taskDestination is a parallel queue, then enqueue algorithm to taskDestination.
@ -21,7 +21,7 @@ int queue_fetch_task(JS::Object& task_destination, JS::SafeFunction<void()> algo
// AD-HOC: This overload allows tracking the queued task within the fetch controller so that we may cancel queued tasks
// when the spec indicates that we must stop an ongoing fetch.
int queue_fetch_task(JS::NonnullGCPtr<FetchController> fetch_controller, JS::Object& task_destination, JS::SafeFunction<void()> algorithm)
int queue_fetch_task(JS::NonnullGCPtr<FetchController> fetch_controller, JS::Object& task_destination, Function<void()> algorithm)
{
auto fetch_task_id = fetch_controller->next_fetch_task_id();

View file

@ -17,7 +17,7 @@ namespace Web::Fetch::Infrastructure {
// FIXME: 'or a parallel queue'
using TaskDestination = Variant<Empty, JS::NonnullGCPtr<JS::Object>>;
int queue_fetch_task(JS::Object&, JS::SafeFunction<void()>);
int queue_fetch_task(JS::NonnullGCPtr<FetchController>, JS::Object&, JS::SafeFunction<void()>);
int queue_fetch_task(JS::Object&, Function<void()>);
int queue_fetch_task(JS::NonnullGCPtr<FetchController>, JS::Object&, Function<void()>);
}