20
20
#ifndef SWIFT_ABI_TASKSTATUS_H
21
21
#define SWIFT_ABI_TASKSTATUS_H
22
22
23
- #include " swift/ABI/Task.h"
24
23
#include " swift/ABI/MetadataValues.h"
24
+ #include " swift/ABI/Task.h"
25
25
26
26
namespace swift {
27
27
@@ -30,7 +30,7 @@ namespace swift {
30
30
// / TaskStatusRecords are typically allocated on the stack (possibly
31
31
// / in the task context), partially initialized, and then atomically
32
32
// / added to the task with `swift_task_addTaskStatusRecord`. While
33
- // / registered with the task, a status record should only be
33
+ // / registered with the task, a status record should only be
34
34
// / modified in ways that respect the possibility of asynchronous
35
35
// / access by a cancelling thread. In particular, the chain of
36
36
// / status records must not be disturbed. When the task leaves
@@ -51,13 +51,9 @@ class TaskStatusRecord {
51
51
TaskStatusRecord (const TaskStatusRecord &) = delete ;
52
52
TaskStatusRecord &operator =(const TaskStatusRecord &) = delete ;
53
53
54
- TaskStatusRecordKind getKind () const {
55
- return Flags.getKind ();
56
- }
54
+ TaskStatusRecordKind getKind () const { return Flags.getKind (); }
57
55
58
- TaskStatusRecord *getParent () const {
59
- return Parent;
60
- }
56
+ TaskStatusRecord *getParent () const { return Parent; }
61
57
62
58
// / Change the parent of this unregistered status record to the
63
59
// / given record.
@@ -77,9 +73,7 @@ class TaskStatusRecord {
77
73
// / Unlike resetParent, this assumes that it's just removing one or
78
74
// / more records from the chain and that there's no need to do any
79
75
// / extra cache manipulation.
80
- void spliceParent (TaskStatusRecord *newParent) {
81
- Parent = newParent;
82
- }
76
+ void spliceParent (TaskStatusRecord *newParent) { Parent = newParent; }
83
77
};
84
78
85
79
// / A deadline for the task. If this is reached, the task will be
@@ -102,14 +96,12 @@ struct TaskDeadline {
102
96
// / within the task.
103
97
class DeadlineStatusRecord : public TaskStatusRecord {
104
98
TaskDeadline Deadline;
99
+
105
100
public:
106
101
DeadlineStatusRecord (TaskDeadline deadline)
107
- : TaskStatusRecord(TaskStatusRecordKind::Deadline),
108
- Deadline (deadline) {}
102
+ : TaskStatusRecord(TaskStatusRecordKind::Deadline), Deadline(deadline) {}
109
103
110
- TaskDeadline getDeadline () const {
111
- return Deadline;
112
- }
104
+ TaskDeadline getDeadline () const { return Deadline; }
113
105
114
106
static bool classof (const TaskStatusRecord *record) {
115
107
return record->getKind () == TaskStatusRecordKind::Deadline;
@@ -123,25 +115,22 @@ class ChildTaskStatusRecord : public TaskStatusRecord {
123
115
124
116
public:
125
117
ChildTaskStatusRecord (AsyncTask *child)
126
- : TaskStatusRecord(TaskStatusRecordKind::ChildTask),
127
- FirstChild (child) {}
118
+ : TaskStatusRecord(TaskStatusRecordKind::ChildTask), FirstChild(child) {}
128
119
129
120
ChildTaskStatusRecord (AsyncTask *child, TaskStatusRecordKind kind)
130
- : TaskStatusRecord(kind),
131
- FirstChild(child) {
121
+ : TaskStatusRecord(kind), FirstChild(child) {
132
122
assert (kind == TaskStatusRecordKind::ChildTask);
133
123
assert (!child->hasGroupChildFragment () &&
134
- " Group child tasks must be tracked in their respective "
135
- " TaskGroupTaskStatusRecord, and not as independent ChildTaskStatusRecord "
136
- " records." );
124
+ " Group child tasks must be tracked in their respective "
125
+ " TaskGroupTaskStatusRecord, and not as independent "
126
+ " ChildTaskStatusRecord "
127
+ " records." );
137
128
}
138
129
139
130
// / Return the first child linked by this record. This may be null;
140
131
// / if not, it (and all of its successors) are guaranteed to satisfy
141
132
// / `isChildTask()`.
142
- AsyncTask *getFirstChild () const {
143
- return FirstChild;
144
- }
133
+ AsyncTask *getFirstChild () const { return FirstChild; }
145
134
146
135
static AsyncTask *getNextChildTask (AsyncTask *task) {
147
136
return task->childFragment ()->getNextChild ();
@@ -175,25 +164,21 @@ class ChildTaskStatusRecord : public TaskStatusRecord {
175
164
// / and are only tracked by their respective `TaskGroupTaskStatusRecord`.
176
165
class TaskGroupTaskStatusRecord : public TaskStatusRecord {
177
166
AsyncTask *FirstChild;
167
+
178
168
public:
179
169
TaskGroupTaskStatusRecord ()
180
- : TaskStatusRecord(TaskStatusRecordKind::TaskGroup),
181
- FirstChild ( nullptr ) { }
170
+ : TaskStatusRecord(TaskStatusRecordKind::TaskGroup), FirstChild( nullptr ) {
171
+ }
182
172
183
173
TaskGroupTaskStatusRecord (AsyncTask *child)
184
- : TaskStatusRecord(TaskStatusRecordKind::TaskGroup),
185
- FirstChild(child) {}
174
+ : TaskStatusRecord(TaskStatusRecordKind::TaskGroup), FirstChild(child) {}
186
175
187
- TaskGroup* getGroup () {
188
- return reinterpret_cast <TaskGroup *>(this );
189
- }
176
+ TaskGroup *getGroup () { return reinterpret_cast <TaskGroup *>(this ); }
190
177
191
178
// / Return the first child linked by this record. This may be null;
192
179
// / if not, it (and all of its successors) are guaranteed to satisfy
193
180
// / `isChildTask()`.
194
- AsyncTask *getFirstChild () const {
195
- return FirstChild;
196
- }
181
+ AsyncTask *getFirstChild () const { return FirstChild; }
197
182
198
183
// / Attach the passed in `child` task to this group.
199
184
void attachChild (AsyncTask *child) {
@@ -207,7 +192,8 @@ class TaskGroupTaskStatusRecord : public TaskStatusRecord {
207
192
return ;
208
193
}
209
194
210
- // We need to traverse the siblings to find the last one and add the child there.
195
+ // We need to traverse the siblings to find the last one and add the child
196
+ // there.
211
197
// FIXME: just set prepend to the current head, no need to traverse.
212
198
213
199
auto cur = FirstChild;
@@ -249,20 +235,18 @@ class TaskGroupTaskStatusRecord : public TaskStatusRecord {
249
235
// / subsequently used.
250
236
class CancellationNotificationStatusRecord : public TaskStatusRecord {
251
237
public:
252
- using FunctionType = SWIFT_CC(swift) void (SWIFT_CONTEXT void *);
238
+ using FunctionType = SWIFT_CC(swift) void (SWIFT_CONTEXT void *);
253
239
254
240
private:
255
- FunctionType * __ptrauth_swift_cancellation_notification_function Function;
241
+ FunctionType *__ptrauth_swift_cancellation_notification_function Function;
256
242
void *Argument;
257
243
258
244
public:
259
245
CancellationNotificationStatusRecord (FunctionType *fn, void *arg)
260
- : TaskStatusRecord(TaskStatusRecordKind::CancellationNotification),
261
- Function (fn), Argument(arg) {}
246
+ : TaskStatusRecord(TaskStatusRecordKind::CancellationNotification),
247
+ Function (fn), Argument(arg) {}
262
248
263
- void run () {
264
- Function (Argument);
265
- }
249
+ void run () { Function (Argument); }
266
250
267
251
static bool classof (const TaskStatusRecord *record) {
268
252
return record->getKind () == TaskStatusRecordKind::CancellationNotification;
@@ -279,20 +263,18 @@ class CancellationNotificationStatusRecord : public TaskStatusRecord {
279
263
// / subsequently used.
280
264
class EscalationNotificationStatusRecord : public TaskStatusRecord {
281
265
public:
282
- using FunctionType = void (void *, JobPriority);
266
+ using FunctionType = void (void *, JobPriority);
283
267
284
268
private:
285
- FunctionType * __ptrauth_swift_escalation_notification_function Function;
269
+ FunctionType *__ptrauth_swift_escalation_notification_function Function;
286
270
void *Argument;
287
271
288
272
public:
289
273
EscalationNotificationStatusRecord (FunctionType *fn, void *arg)
290
- : TaskStatusRecord(TaskStatusRecordKind::EscalationNotification),
291
- Function (fn), Argument(arg) {}
274
+ : TaskStatusRecord(TaskStatusRecordKind::EscalationNotification),
275
+ Function (fn), Argument(arg) {}
292
276
293
- void run (JobPriority newPriority) {
294
- Function (Argument, newPriority);
295
- }
277
+ void run (JobPriority newPriority) { Function (Argument, newPriority); }
296
278
297
279
static bool classof (const TaskStatusRecord *record) {
298
280
return record->getKind () == TaskStatusRecordKind::EscalationNotification;
0 commit comments