Skip to content

Commit 2269ec1

Browse files
committed
Add specification for scheduler.yield() method
1 parent 9825447 commit 2269ec1

File tree

3 files changed

+224
-59
lines changed

3 files changed

+224
-59
lines changed

spec/controlling-tasks.md

+9
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ object |signal|, [=set/append=] |algorithm| to |signal|'s [=TaskSignal/priority
193193
1. Set |signal|'s [=TaskSignal/priority changing=] to false.
194194
</div>
195195

196+
<div algorithm>
197+
To <dfn>create a fixed priority unabortable task signal</dfn> given {{TaskPriority}} |priority|
198+
and a |realm|.
199+
200+
1. Let |init| be a new {{TaskSignalAnyInit}}.
201+
1. Set |init|["{{TaskSignalAnyInit/priority}}"] to |priority|.
202+
1. Return the result of [=creating a dependent task signal=] from « », |init|, and |realm|.
203+
</div>
204+
196205
### Garbage Collection ### {#sec-task-signal-garbage-collection}
197206

198207
A [=TaskSignal/dependent=] {{TaskSignal}} object must not be garbage collected while its

spec/patches.md

+46
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ determine task execution order across [=scheduler task queues=] of the same {{Ta
3232
all {{Scheduler}}s associated with the same [=event loop=]. A timestamp would also suffice as long
3333
as it is guaranteed to be strictly increasing and unique.
3434

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.
37+
3538
### <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}
3639

3740
Add the following steps to the event loop processing steps, before step 2:
@@ -56,3 +59,46 @@ Issue: The |taskQueue| in this step will either be a [=set=] of [=tasks=] or a [
5659
[=scheduler tasks=]. The steps that follow only [=set/remove=] an [=set/item=], so they are
5760
*roughly* compatible. Ideally, there would be a common task queue interface that supports a `pop()`
5861
method that would return a plain [=task=], but that would involve a fair amount of refactoring.
62+
63+
### <a href="https://html.spec.whatwg.org/multipage/webappapis.html#hostmakejobcallback">HostMakeJobCallback(callable)</a> ### {#sec-patches-html-hostmakejobcallback}
64+
65+
Add the following before step 5:
66+
67+
1. Let |state| be the [=incumbent realm=]'s [=realm/agent=]'s associated [=event loop=]'s
68+
[=event loop/current scheduling state=].
69+
70+
Modify step 5 to read:
71+
72+
1. Return the <span>JobCallback Record</span> { `[[Callback]]`: <var ignore=''>callable</var>,
73+
`[[HostDefined]]`: { `[[IncumbentSettings]]`: <var ignore=''>incumbent settings</var>,
74+
`[[ActiveScriptContext]]`: <var ignore=''>script execution context</var>,
75+
`[[SchedulingState]]`: |state| } }.
76+
77+
### <a href="https://html.spec.whatwg.org/multipage/webappapis.html#hostcalljobcallback">HostCallJobCallback(callback, V, argumentsList)</a> ### {#sec-patches-html-hostcalljobcallback}
78+
79+
Add the following steps before step 5:
80+
81+
1. Let |event loop| be the [=incumbent realm=]'s [=realm/agent=]'s associated [=event loop=].
82+
1. Set |event loop|'s [=event loop/current scheduling state=] to
83+
<var ignore=''>callback</var>.`[[HostDefined]]`.`[[SchedulingState]]`.
84+
85+
Add the following after step 7:
86+
87+
1. Set |event loop|'s [=event loop/current scheduling state=] to null.
88+
89+
## <a href="https://w3c.github.io/requestidlecallback/">`requestIdleCallback()`</a> ## {#sec-patches-requestidlecallback}
90+
91+
### <a href="https://w3c.github.io/requestidlecallback/#invoke-idle-callbacks-algorithm">Invoke idle callbacks algorithm</a> ### {#sec-patches-invoke-idle-callbacks}
92+
93+
Add the following step before step 3.3:
94+
95+
1. Let |realm| be <var ignore=''> window's [=relevant realm=].
96+
1. Let |state| be a new [=scheduling state=].
97+
1. Set |state|'s [=scheduling state/priority source=] to the result of [=creating a fixed priority
98+
unabortable task signal=] given "{{TaskPriority/background}}" and |realm|.
99+
1. Let |event loop| be |realm|'s [=realm/agent=]'s associated [=event loop=].
100+
1. Set |event loop|'s [=event loop/current scheduling state=] to |state|.
101+
102+
Add the following after step 3.3:
103+
104+
1. Set |event loop|'s [=event loop/current scheduling state=] to null.

0 commit comments

Comments
 (0)