From 0465cfc6e0b652006659e45bf5ddc2f505b0b6c5 Mon Sep 17 00:00:00 2001
From: Ross McIlroy
Date: Wed, 30 Oct 2019 12:10:00 +0000
Subject: [PATCH] Associcate idle callback lists and idle periods with the
event loop.
The idle callback lists and idle periods should be per-event loop
rather than per-window. This change moves the lists and the starting
of idle periods to be on a per-event loop basis.
Addresses #82
---
index.html | 79 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 47 insertions(+), 32 deletions(-)
diff --git a/index.html b/index.html
index b0060bf..152c172 100644
--- a/index.html
+++ b/index.html
@@ -341,19 +341,24 @@ Window
interface extensions
Each Window has:
- - A list of idle request callbacks. The list MUST be
- initially empty and each entry in this list is identified by a number,
- which MUST be unique within the list for the lifetime of the
Window
- object.
- - A list of runnable idle callbacks. The list MUST be
- initially empty and each entry in this list is identified by a number,
- which MUST be unique within the list of the lifetime of the
Window
- object.
- An idle callback identifier, which is a number which MUST
initially be zero.
+
+
+ In addition, each event loop has:
+
+ - A list of idle request callbacks. The list MUST be
+ initially empty and each entry in this list is identified by Window
+ and a number, the combination of which MUST be unique within the list for
+ the lifetime of the event loop.
+ - A list of runnable idle callbacks. The list MUST be
+ initially empty and each entry in this list is identified by a
+ Window and a number, the combination of which which MUST be unique
+ within the list for the lifetime of the event loop.
- A last idle period deadline, which is a
DOMHighResTimeStamp which MUST initially be zero.
+
The requestIdleCallback
method
@@ -367,8 +372,11 @@ The requestIdleCallback
by one.
Let handle be the current value of window's
idle callback identifier.
- Push callback to the end of window's list
- of idle request callbacks, associated with handle.
+ Let event_loop be the event loop associated with
+ window
+ Push callback to the end of event_loop's
+ list of idle request callbacks, associated with handle
+ and window.
Return handle and then continue running this algorithm
asynchronously.
The following steps run in parallel and queue a timer
@@ -421,11 +429,13 @@
The cancelIdleCallback
- Let window be this
Window
object.
- - Find the entry in either the window's list of idle
+
- Let event_loop be the event loop associated with
+ window
+ - Find the entry in either the event_loop's list of idle
request callbacks or list of runnable idle callbacks that is
- associated with the value handle.
+ associated with the value handle and window.
- - If there is such an entry, remove it from both window's
+
- If there is such an entry, remove it from both event_loop's
list of idle request callbacks and the list of runnable idle
callbacks.
@@ -479,7 +489,7 @@ Start an idle period algorithm
the event loop is otherwise idle:
- Let last_deadline be the last idle period deadline
- associated with window
+ associated with event_loop
- If last_deadline is greater than the current time,
return from this algorithm.
- Optionally, if the user agent determines the idle period should
@@ -509,11 +519,11 @@
Start an idle period algorithm
responsiveness to new user input within the threshold of human
perception.
- - Let pending_list be window's list of idle
- request callbacks.
+
- Let pending_list be event_loop's list of
+ idle request callbacks.
- - Let run_list be window's list of runnable
- idle callbacks.
+
- Let run_list be event_loop's list of
+ runnable idle callbacks.
- Append all entries from pending_list into
run_list preserving order.
@@ -521,19 +531,20 @@ Start an idle period algorithm
- Queue a task on the queue associated with the idle-task
task source, which performs the steps defined in the invoke
idle callbacks algorithm with deadline and
- window as parameters.
+ event_loop as parameters.
- Save deadline as the last idle period deadline
- associated with window.
+ associated with event_loop.
The task source for these tasks is the idle-task
task source.
The time between now and deadline is referred
to as the idle period. There can only be one idle period
- active at a given time for any given window
. The idle period can end
- early if the user agent determines that it is no longer idle. If so,
- the next idle period cannot start until after deadline.
+ active at a given time for any given
event loop. The idle period
+ can end early if the user agent determines that it is no longer idle. If
+ so, the next idle period cannot start until after
deadline.
+