LibWeb: Port EventLoop::spin_XXX to HeapFunction

This commit is contained in:
Shannon Booth 2024-10-31 05:23:43 +13:00 committed by Alexander Kalenik
parent 29cea5bd24
commit 1c18b900e2
Notes: github-actions[bot] 2024-10-30 19:57:02 +00:00
14 changed files with 68 additions and 65 deletions

View file

@ -298,9 +298,9 @@ void EventSource::reestablish_the_connection()
}));
// 2. Wait a delay equal to the reconnection time of the event source.
HTML::main_thread_event_loop().spin_until([&, delay_start = MonotonicTime::now()]() {
HTML::main_thread_event_loop().spin_until(JS::create_heap_function(heap(), [&, delay_start = MonotonicTime::now()]() {
return (MonotonicTime::now() - delay_start) >= m_reconnection_time;
});
}));
// 3. Optionally, wait some more. In particular, if the previous attempt failed, then user agents might introduce
// an exponential backoff delay to avoid overloading a potentially already overloaded server. Alternatively, if
@ -309,7 +309,7 @@ void EventSource::reestablish_the_connection()
// 4. Wait until the aforementioned task has run, if it has not yet run.
if (!initial_task_has_run) {
HTML::main_thread_event_loop().spin_until([&]() { return initial_task_has_run; });
HTML::main_thread_event_loop().spin_until(JS::create_heap_function(heap(), [&]() { return initial_task_has_run; }));
}
// 5. Queue a task to run the following steps: