1
- Controlling Tasks {#sec-controlling-tasks}
2
- =====================
1
+ # Controlling Tasks # {#sec-controlling-tasks}
3
2
4
- Tasks scheduled through the {{Scheduler}} interface can be controlled with a
5
- {{TaskController}} by passing the {{TaskSignal}} provided by
6
- {{AbortController/signal|controller.signal}} as the
7
- {{SchedulerPostTaskOptions/signal|option}} when calling {{Scheduler/postTask()}}.
8
- The {{TaskController}} interface supports aborting and changing the priority of
9
- a task or group of tasks.
3
+ Tasks scheduled through the {{Scheduler}} interface can be controlled with a {{TaskController}} by
4
+ passing the {{TaskSignal}} provided by {{AbortController/signal|controller.signal}} as the
5
+ {{SchedulerPostTaskOptions/signal|option}} when calling {{Scheduler/postTask()}}. The
6
+ {{TaskController}} interface supports aborting and changing the priority of a task or group of
7
+ tasks.
10
8
11
- The ` TaskPriorityChangeEvent ` Interface {#sec-task-priority-change-event}
12
- ---------------------
9
+ ## The ` TaskPriorityChangeEvent ` Interface ## {#sec-task-priority-change-event}
13
10
14
11
<pre class =' idl ' >
15
12
[Exposed=(Window, Worker)]
@@ -27,19 +24,17 @@ The `TaskPriorityChangeEvent` Interface {#sec-task-priority-change-event}
27
24
<dl class =" domintro non-normative " >
28
25
<dt ><code >event . {{TaskPriorityChangeEvent/previousPriority}}</code ></dt >
29
26
<dd >
30
- <p>Returns the {{TaskPriority}} of the corresponding {{TaskSignal}} prior to
31
- this `prioritychange` event.
27
+ <p>Returns the {{TaskPriority}} of the corresponding {{TaskSignal}} prior to this
28
+ `prioritychange` event.
32
29
33
30
<p>The new {{TaskPriority}} can be read with `event.target.priority`.
34
31
</dd >
35
32
</dl >
36
33
37
- The <dfn attribute for =TaskPriorityChangeEvent >previousPriority</dfn > getter
38
- steps are to return the value that the corresponding attribute was initialized
39
- to.
34
+ The <dfn attribute for =TaskPriorityChangeEvent >previousPriority</dfn > getter steps are to return the
35
+ value that the corresponding attribute was initialized to.
40
36
41
- The ` TaskController ` Interface {#sec-task-controller}
42
- ---------------------
37
+ ## The ` TaskController ` Interface ## {#sec-task-controller}
43
38
44
39
<pre class =' idl ' >
45
40
dictionary TaskControllerInit {
@@ -54,22 +49,21 @@ The `TaskController` Interface {#sec-task-controller}
54
49
};
55
50
</pre >
56
51
57
- Note: {{TaskController}}'s {{AbortController/signal}} getter, which is
58
- inherited from {{AbortController}}, returns a {{TaskSignal}} object.
52
+ Note: {{TaskController}}'s {{AbortController/signal}} getter, which is inherited from
53
+ {{AbortController}}, returns a {{TaskSignal}} object.
59
54
60
55
<dl class =" domintro non-normative " >
61
56
<dt ><code >controller = new {{TaskController/TaskController()|TaskController}}( |init| )</code >
62
57
<dd >
63
- <p> Returns a new {{TaskController}} whose {{AbortController/signal}} is
64
- set to a newly created {{TaskSignal}} with its {{TaskSignal/priority}}
65
- initialized to |init|'s {{TaskControllerInit/priority}}.
58
+ <p> Returns a new {{TaskController}} whose {{AbortController/signal}} is set to a newly created
59
+ {{TaskSignal}} with its {{TaskSignal/priority}} initialized to |init|'s
60
+ {{TaskControllerInit/priority}}.
66
61
</dd >
67
62
68
63
<dt ><code >controller . {{TaskController/setPriority()|setPriority}}( |priority| )</code >
69
64
<dd >
70
- <p>Invoking this method will change the associated {{TaskSignal}}'s
71
- [=TaskSignal/priority=], signal the priority change to any observers, and
72
- cause `prioritychange` events to be dispatched.
65
+ <p>Invoking this method will change the associated {{TaskSignal}}'s [=TaskSignal/priority=],
66
+ signal the priority change to any observers, and cause `prioritychange` events to be dispatched.
73
67
</dd >
74
68
</dl >
75
69
@@ -82,12 +76,10 @@ inherited from {{AbortController}}, returns a {{TaskSignal}} object.
82
76
1 . Set [ =this's=] [ =AbortController/signal=] to |signal|.
83
77
</div >
84
78
85
- The <dfn method for =TaskController ><code >setPriority(|priority|)</code ></dfn >
86
- method steps are to [ =TaskSignal/signal priority change=] on [ =this=] 's
87
- [ =AbortController/signal=] given |priority|.
79
+ The <dfn method for =TaskController ><code >setPriority(|priority|)</code ></dfn > method steps are to
80
+ [ =TaskSignal/signal priority change=] on [ =this=] 's [ =AbortController/signal=] given |priority|.
88
81
89
- The ` TaskSignal ` Interface {#sec-task-signal}
90
- ---------------------
82
+ ## The ` TaskSignal ` Interface ## {#sec-task-signal}
91
83
92
84
<pre class =' idl ' >
93
85
dictionary TaskSignalAnyInit {
@@ -104,9 +96,9 @@ The `TaskSignal` Interface {#sec-task-signal}
104
96
};
105
97
</pre >
106
98
107
- Note: {{TaskSignal}} inherits from {{AbortSignal}} and can be used in APIs that
108
- accept an {{AbortSignal}}. Additionally, {{Scheduler/postTask()}} accepts an
109
- {{AbortSignal}}, which can be useful if dynamic prioritization is not needed.
99
+ Note: {{TaskSignal}} inherits from {{AbortSignal}} and can be used in APIs that accept an
100
+ {{AbortSignal}}. Additionally, {{Scheduler/postTask()}} accepts an {{AbortSignal}}, which can be
101
+ useful if dynamic prioritization is not needed.
110
102
111
103
<dl class =" domintro non-normative " >
112
104
<dt ><code >TaskSignal . <a method for =TaskSignal lt =" any(signals, init) " >any</a >(|signals|, |init|)</code >
@@ -137,30 +129,32 @@ A {{TaskSignal}} object has associated <dfn for=TaskSignal>dependent signals</df
137
129
of {{TaskSignal}} objects that are dependent on the object for their [ =TaskSignal/priority=] ), which
138
130
is initially empty.
139
131
140
- A {{TaskSignal}} object has an associated <dfn for =TaskSignal >dependent</dfn > (a
141
- boolean), which is initially false.
132
+ A {{TaskSignal}} object has an associated <dfn for =TaskSignal >dependent</dfn > (a boolean), which is
133
+ initially false.
142
134
143
- <br >
135
+ <hr >
144
136
145
- The <dfn attribute for =" TaskSignal " >priority</dfn > getter steps are to return
146
- [ =this= ] 's [ = TaskSignal/priority=] .
137
+ The <dfn attribute for =" TaskSignal " >priority</dfn > getter steps are to return [ =this= ] 's
138
+ [ =TaskSignal/priority=] .
147
139
148
- The <dfn attribute for =TaskSignal ><code >onprioritychange</code ></dfn > attribute
149
- is an [ =event handler IDL attribute=] for the ` onprioritychange `
150
- [ =event handler=] , whose [ =event handler event type=] is
151
- <dfn event for =TaskSignal >prioritychange</dfn >.
140
+ The <dfn attribute for =TaskSignal ><code >onprioritychange</code ></dfn > attribute is an [ =event
141
+ handler IDL attribute=] for the ` onprioritychange ` [ =event handler=] , whose [ =event handler event
142
+ type=] is <dfn event for =TaskSignal >prioritychange</dfn >.
152
143
153
- To <dfn for =" TaskSignal " >add a priority change algorithm</dfn > |algorithm| to a
154
- {{TaskSignal}} object |signal|, [ =set/append=] |algorithm| to |signal|'s
155
- [ =TaskSignal/priority change algorithms=] .
144
+ The static <dfn method for =TaskSignal ><code >any(|signals|, |init|)</code ></dfn > method steps are to
145
+ return the result of [ =creating a dependent task signal=] from |signals| and |init|.
156
146
157
- <br >
147
+ <hr >
158
148
159
149
A {{TaskSignal}} <dfn for =TaskSignal lt =" has fixed priority|have fixed priority " >has fixed priority</dfn >
160
150
if it is a [ =TaskSignal/dependent=] signal with a null [ =TaskSignal/source signal=] .
161
151
152
+ To <dfn for =" TaskSignal " >add a priority change algorithm</dfn > |algorithm| to a {{TaskSignal}}
153
+ object |signal|, [ =set/append=] |algorithm| to |signal|'s [ =TaskSignal/priority change algorithms=] .
154
+
162
155
<div algorithm >
163
- The static <dfn method for =TaskSignal ><code >any(|signals|, |init|)</code ></dfn > method steps are:
156
+ To <dfn >create a dependent task signal</dfn > from a [ =list=] of {{AbortSignal}} objects |signals|
157
+ and a {{TaskSignalAnyInit}} |init|:
164
158
165
159
1 . Let |resultSignal| be the result of <a for =AbortSignal >creating a dependent signal</a > from
166
160
|signals| using the {{TaskSignal}} interface and the [ =current realm=] .
@@ -180,8 +174,8 @@ if it is a [=TaskSignal/dependent=] signal with a null [=TaskSignal/source signa
180
174
</div >
181
175
182
176
<div algorithm >
183
- To <dfn for =" TaskSignal " >signal priority change</dfn > on a {{TaskSignal}}
184
- object |signal|, given a {{TaskPriority}} |priority|:
177
+ To <dfn for =" TaskSignal " >signal priority change</dfn > on a {{TaskSignal}} object |signal|, given a
178
+ {{TaskPriority}} |priority|:
185
179
186
180
1 . If |signal|'s [ =TaskSignal/priority changing=] is true, then [ =exception/throw=]
187
181
a "{{NotAllowedError!!exception}}" {{DOMException}}.
@@ -205,7 +199,6 @@ A [=TaskSignal/dependent=] {{TaskSignal}} object must not be garbage collected w
205
199
[ =TaskSignal/source signal=] is non-null and it has registered event listeners for its
206
200
{{TaskSignal/prioritychange}} event or its [ =TaskSignal/priority change algorithms=] is non-empty.
207
201
208
- Examples {#sec-controlling-tasks-examples}
209
- ---------------------
202
+ ## Examples ## {#sec-controlling-tasks-examples}
210
203
211
204
** TODO** (shaseley): Add examples.
0 commit comments