@@ -32,8 +32,30 @@ determine task execution order across [=scheduler task queues=] of the same {{Ta
32
32
all {{Scheduler}}s associated with the same [ =event loop=] . A timestamp would also suffice as long
33
33
as it is guaranteed to be strictly increasing and unique.
34
34
35
- Add: An [ =event loop=] has a <dfn for =" event loop " >current scheduling state</dfn > (a [ =scheduling
36
- state=] or null), which is initialized to null.
35
+ Add: An [ =event loop=] has a <dfn for =" event loop " >current continuation state</dfn > (a
36
+ [ =continuation state=] or null), which is initially null.
37
+
38
+ Add the following algorithms:
39
+
40
+ <div algorithm >
41
+ To <dfn >set the continuation state value</dfn > for |key| to |value| given an |eventLoop| (an
42
+ [ =event loop=] ):
43
+
44
+ 1 . If |eventLoop|'s [ =event loop/current continuation state=] is null, then set |eventLoop|'s
45
+ [ =event loop/current continuation state=] to a new [ =continuation state=] .
46
+ 1 . Let |continuationState| be |eventLoop|'s [ =event loop/current continuation state=] .
47
+ 1 . Assert: |continuationState|'s [ =continuation state/state map=] [ |key| ] does not [ =map/exist=] .
48
+ 1 . Set |continuationState|'s [ =continuation state/state map=] [ |key| ] to |value|.
49
+ </div >
50
+
51
+ <div algorithm >
52
+ To <dfn >get the continuation state value</dfn > for |key| given an |eventLoop| (an [ =event loop=] ):
53
+
54
+ 1 . Let |continuationState| be |eventLoop|'s [ =event loop/current continuation state=] .
55
+ 1 . If |continuationState| is not null and |continuationState|'s
56
+ [ =continuation state/state map=] [ |key| ] [ =map/exists=] , then return |continuationState|'s
57
+ [ =continuation state/state map=] [ |key| ] , otherwise return null.
58
+ </div >
37
59
38
60
### <a href =" https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model " >Event loop: processing model</a > ### {#sec-patches-html-event-loop-processing}
39
61
@@ -80,33 +102,59 @@ Issue: The |taskQueue| in this step will either be a [=set=] of [=tasks=] or a [
80
102
* roughly* compatible. Ideally, there would be a common task queue interface that supports a ` pop() `
81
103
method that would return a plain [ =task=] , but that would involve a fair amount of refactoring.
82
104
105
+ ### <a href =" https://html.spec.whatwg.org/#queuing-tasks " >Event Loop: Queuing Tasks</a > ### {#sec-patches-html-queuing-tasks}
106
+
107
+ Change the <a href =" https://html.spec.whatwg.org/#queue-a-microtask " >To queue a microtask</a >
108
+ algorithm to accept an optional boolean |ignoreContinuationState| (default false).
109
+
110
+ Change Step 5 to the following:
111
+
112
+ 1 . Let |continuationState| be null.
113
+ 1 . If |ignoreContinuationState| is false and |eventLoop|'s
114
+ [ =event loop/current continuation state=] is not null, then set |continuationState| to the
115
+ result of [ =list/cloning=] |event loop|'s [ =event loop/current continuation state=] .
116
+ 1 . Set <var ignore =' ' >microtask</var >'s <a attribute for =" task " >steps</a > to the following:
117
+ 1 . If |ignoreContinuationState| is false, then set |eventLoop|'s
118
+ [ =event loop/current continuation state=] to |continuationState|.
119
+ 1 . Run <var ignore =' ' >steps</var >.
120
+ 1 . If |ignoreContinuationState| is false, then set |eventLoop|'s
121
+ [ =event loop/current continuation state=] to null.
122
+
83
123
### <a href =" https://html.spec.whatwg.org/multipage/webappapis.html#hostmakejobcallback " >HostMakeJobCallback(callable)</a > ### {#sec-patches-html-hostmakejobcallback}
84
124
85
125
Add the following before step 5:
86
126
87
127
1 . Let |event loop| be <var ignore =' ' >incumbent settings<var >'s
88
128
[ =environment settings object/realm=] 's [ =realm/agent=] 's [ =agent/event loop=] .
89
- 1 . Let |state| be |event loop|'s [ =event loop/current scheduling state=] .
129
+ 1 . Let |state| be the result of [ =list/cloning=] |event loop|'s
130
+ [ =event loop/current continuation state=] if [ =event loop/current continuation state=] is not
131
+ null, or otherwise null.
90
132
91
133
Modify step 5 to read:
92
134
93
135
1 . Return the <span >JobCallback Record</span > { \[ [ Callback]] : <var ignore =' ' >callable</var >,
94
136
\[ [ HostDefined]] : { \[ [ IncumbentSettings]] : <var ignore =' ' >incumbent settings</var >,
95
137
\[ [ ActiveScriptContext]] : <var ignore =' ' >script execution context</var >,
96
- \[ [ SchedulingState ]] : |state| } }.
138
+ \[ [ ContinuationState ]] : |state| } }.
97
139
98
140
### <a href =" https://html.spec.whatwg.org/multipage/webappapis.html#hostcalljobcallback " >HostCallJobCallback(callback, V, argumentsList)</a > ### {#sec-patches-html-hostcalljobcallback}
99
141
100
142
Add the following steps before step 5:
101
143
102
144
1 . Let |event loop| be <var ignore =' ' >incumbent settings<var >'s
103
145
[ =environment settings object/realm=] 's [ =realm/agent=] 's [ =agent/event loop=] .
104
- 1 . Set |event loop|'s [ =event loop/current scheduling state=] to
105
- <var ignore =' ' >callback</var >.\[ [ HostDefined]] .\[ [ SchedulingState ]] .
146
+ 1 . Set |event loop|'s [ =event loop/current continuation state=] to
147
+ <var ignore =' ' >callback</var >.\[ [ HostDefined]] .\[ [ ContinuationState ]] .
106
148
107
149
Add the following after step 7:
108
150
109
- 1 . Set |event loop|'s [ =event loop/current scheduling state=] to null.
151
+ 1 . Set |event loop|'s [ =event loop/current continuation state=] to null.
152
+
153
+ ### <a href =" https://html.spec.whatwg.org/multipage/webappapis.html#hostenqueuepromisejob " >HostEnqueuePromiseJob(job, realm)</a > ### {#sec-patches-html-hostenqueuepromisejob}
154
+
155
+ Change step 2 to:
156
+
157
+ 1 . Queue a microtask to perform the following steps with |ignoreContinuationState| set to true:
110
158
111
159
## <a href =" https://w3c.github.io/requestidlecallback/ " >` requestIdleCallback() ` </a > ## {#sec-patches-requestidlecallback}
112
160
@@ -118,9 +166,9 @@ Add the following step before step 3.3:
118
166
1 . Let |state| be a new [ =scheduling state=] .
119
167
1 . Set |state|'s [ =scheduling state/priority source=] to the result of [ =creating a fixed priority
120
168
unabortable task signal=] given "{{TaskPriority/background}}" and |realm|.
121
- 1 . Let |event loop | be |realm|'s [ = realm/agent= ] 's [ =agent/event loop= ] .
122
- 1 . Set |event loop|'s [ =event loop/ current scheduling state=] to |state|.
169
+ 1 . Let |scheduler | be the {{Scheduler}} whose [ =relevant realm= ] is |realm| .
170
+ 1 . [ =Set the current scheduling state=] for |scheduler| to |state|.
123
171
124
172
Add the following after step 3.3:
125
173
126
- 1 . Set |event loop|'s [ =event loop/current scheduling state=] to null.
174
+ 1 . Set |event loop|'s [ =event loop/current continuation state=] to null.
0 commit comments