Skip to content

Commit b3b6a19

Browse files
committed
Set queue earlier
1 parent ac03d18 commit b3b6a19

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

spec/scheduling-tasks.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ A <dfn>task handle</dfn> is a [=struct=] with the following [=struct/items=]:
268268
1. Let |priority| be |options|["{{SchedulerPostTaskOptions/priority}}"] if
269269
|options|["{{SchedulerPostTaskOptions/priority}}"] [=map/exists=], or otherwise null.
270270
1. Let |enqueueSteps| be the following steps:
271-
1. Let |queue| be the result of [=selecting the scheduler task queue=] for |scheduler| given
272-
|signal| and |priority|.
273-
1. [=Schedule a task to invoke a callback=] for |scheduler| given |queue|, |callback|, |result|,
274-
and |handle|.
271+
1. Set |handle|'s [=task handle/queue=] to the result of [=selecting the scheduler task queue=]
272+
for |scheduler| given |signal| and |priority|.
273+
1. [=Schedule a task to invoke a callback=] for |scheduler| given |callback|, |result|, and
274+
|handle|.
275275
1. Let |delay| be |options|["{{SchedulerPostTaskOptions/delay}}"].
276276
1. If |delay| is greater than 0, then [=run steps after a timeout=] given |scheduler|'s [=relevant
277277
global object=], "`scheduler-postTask`", |delay|, and the following steps:
@@ -314,21 +314,19 @@ Issue: [=Run steps after a timeout=] doesn't necessarily account for suspension;
314314

315315
<div algorithm>
316316
To <dfn>schedule a task to invoke a callback</dfn> for {{Scheduler}} |scheduler| given a
317-
[=scheduler task queue=] |queue|, a {{SchedulerPostTaskCallback}} |callback|, a promise |result|,
318-
and a [=task handle=] |handle|:
317+
{{SchedulerPostTaskCallback}} |callback|, a promise |result|, and a [=task handle=] |handle|:
319318

320319
1. Let |global| be the [=relevant global object=] for |scheduler|.
321320
1. Let |document| be |global|'s <a attribute for="Window">associated `Document`</a> if |global| is
322321
a {{Window}} object; otherwise null.
323322
1. Let |enqueue order| be |scheduler|'s [=Scheduler/next enqueue order=].
324323
1. Increment |scheduler|'s [=Scheduler/next enqueue order=] by 1.
325-
1. Let |task| be the result of [=queuing a scheduler task=] on |queue| given |enqueue order|,
326-
[=the posted task task source=], and |document|, and that performs the following steps:
324+
1. Set |handle|'s [=task handle/task=] to the result of [=queuing a scheduler task=] on |handle|'s
325+
[=task handle/queue=] given |enqueue order|, [=the posted task task source=], and |document|,
326+
and that performs the following steps:
327327
1. Let |callback result| be the result of [=invoking=] |callback|. If that threw an exception,
328328
then [=reject=] |result| with that, otherwise resolve |result| with |callback result|.
329329
1. Run |handle|'s [=task handle/task complete steps=].
330-
1. Set |handle|'s [=task handle/task=] to |task|.
331-
1. Set |handle|'s [=task handle/queue=] to |queue|.
332330

333331
Issue: Because this algorithm can be called from [=in parallel=] steps, parts of this and other
334332
algorithms are racy. Specifically, the [=Scheduler/next enqueue order=] should be updated

0 commit comments

Comments
 (0)