2020#ifndef SWIFT_ABI_TASKSTATUS_H
2121#define SWIFT_ABI_TASKSTATUS_H
2222
23- #include " swift/ABI/Task.h"
2423#include " swift/ABI/MetadataValues.h"
24+ #include " swift/ABI/Task.h"
2525
2626namespace swift {
2727
@@ -30,7 +30,7 @@ namespace swift {
3030// / TaskStatusRecords are typically allocated on the stack (possibly
3131// / in the task context), partially initialized, and then atomically
3232// / 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
3434// / modified in ways that respect the possibility of asynchronous
3535// / access by a cancelling thread. In particular, the chain of
3636// / status records must not be disturbed. When the task leaves
@@ -51,13 +51,9 @@ class TaskStatusRecord {
5151 TaskStatusRecord (const TaskStatusRecord &) = delete ;
5252 TaskStatusRecord &operator =(const TaskStatusRecord &) = delete ;
5353
54- TaskStatusRecordKind getKind () const {
55- return Flags.getKind ();
56- }
54+ TaskStatusRecordKind getKind () const { return Flags.getKind (); }
5755
58- TaskStatusRecord *getParent () const {
59- return Parent;
60- }
56+ TaskStatusRecord *getParent () const { return Parent; }
6157
6258 // / Change the parent of this unregistered status record to the
6359 // / given record.
@@ -77,9 +73,7 @@ class TaskStatusRecord {
7773 // / Unlike resetParent, this assumes that it's just removing one or
7874 // / more records from the chain and that there's no need to do any
7975 // / extra cache manipulation.
80- void spliceParent (TaskStatusRecord *newParent) {
81- Parent = newParent;
82- }
76+ void spliceParent (TaskStatusRecord *newParent) { Parent = newParent; }
8377};
8478
8579// / A deadline for the task. If this is reached, the task will be
@@ -102,14 +96,12 @@ struct TaskDeadline {
10296// / within the task.
10397class DeadlineStatusRecord : public TaskStatusRecord {
10498 TaskDeadline Deadline;
99+
105100public:
106101 DeadlineStatusRecord (TaskDeadline deadline)
107- : TaskStatusRecord(TaskStatusRecordKind::Deadline),
108- Deadline (deadline) {}
102+ : TaskStatusRecord(TaskStatusRecordKind::Deadline), Deadline(deadline) {}
109103
110- TaskDeadline getDeadline () const {
111- return Deadline;
112- }
104+ TaskDeadline getDeadline () const { return Deadline; }
113105
114106 static bool classof (const TaskStatusRecord *record) {
115107 return record->getKind () == TaskStatusRecordKind::Deadline;
@@ -123,25 +115,22 @@ class ChildTaskStatusRecord : public TaskStatusRecord {
123115
124116public:
125117 ChildTaskStatusRecord (AsyncTask *child)
126- : TaskStatusRecord(TaskStatusRecordKind::ChildTask),
127- FirstChild (child) {}
118+ : TaskStatusRecord(TaskStatusRecordKind::ChildTask), FirstChild(child) {}
128119
129120 ChildTaskStatusRecord (AsyncTask *child, TaskStatusRecordKind kind)
130- : TaskStatusRecord(kind),
131- FirstChild(child) {
121+ : TaskStatusRecord(kind), FirstChild(child) {
132122 assert (kind == TaskStatusRecordKind::ChildTask);
133123 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." );
137128 }
138129
139130 // / Return the first child linked by this record. This may be null;
140131 // / if not, it (and all of its successors) are guaranteed to satisfy
141132 // / `isChildTask()`.
142- AsyncTask *getFirstChild () const {
143- return FirstChild;
144- }
133+ AsyncTask *getFirstChild () const { return FirstChild; }
145134
146135 static AsyncTask *getNextChildTask (AsyncTask *task) {
147136 return task->childFragment ()->getNextChild ();
@@ -175,25 +164,21 @@ class ChildTaskStatusRecord : public TaskStatusRecord {
175164// / and are only tracked by their respective `TaskGroupTaskStatusRecord`.
176165class TaskGroupTaskStatusRecord : public TaskStatusRecord {
177166 AsyncTask *FirstChild;
167+
178168public:
179169 TaskGroupTaskStatusRecord ()
180- : TaskStatusRecord(TaskStatusRecordKind::TaskGroup),
181- FirstChild ( nullptr ) { }
170+ : TaskStatusRecord(TaskStatusRecordKind::TaskGroup), FirstChild( nullptr ) {
171+ }
182172
183173 TaskGroupTaskStatusRecord (AsyncTask *child)
184- : TaskStatusRecord(TaskStatusRecordKind::TaskGroup),
185- FirstChild(child) {}
174+ : TaskStatusRecord(TaskStatusRecordKind::TaskGroup), FirstChild(child) {}
186175
187- TaskGroup* getGroup () {
188- return reinterpret_cast <TaskGroup *>(this );
189- }
176+ TaskGroup *getGroup () { return reinterpret_cast <TaskGroup *>(this ); }
190177
191178 // / Return the first child linked by this record. This may be null;
192179 // / if not, it (and all of its successors) are guaranteed to satisfy
193180 // / `isChildTask()`.
194- AsyncTask *getFirstChild () const {
195- return FirstChild;
196- }
181+ AsyncTask *getFirstChild () const { return FirstChild; }
197182
198183 // / Attach the passed in `child` task to this group.
199184 void attachChild (AsyncTask *child) {
@@ -207,7 +192,8 @@ class TaskGroupTaskStatusRecord : public TaskStatusRecord {
207192 return ;
208193 }
209194
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.
211197 // FIXME: just set prepend to the current head, no need to traverse.
212198
213199 auto cur = FirstChild;
@@ -249,20 +235,18 @@ class TaskGroupTaskStatusRecord : public TaskStatusRecord {
249235// / subsequently used.
250236class CancellationNotificationStatusRecord : public TaskStatusRecord {
251237public:
252- using FunctionType = SWIFT_CC(swift) void (SWIFT_CONTEXT void *);
238+ using FunctionType = SWIFT_CC(swift) void (SWIFT_CONTEXT void *);
253239
254240private:
255- FunctionType * __ptrauth_swift_cancellation_notification_function Function;
241+ FunctionType *__ptrauth_swift_cancellation_notification_function Function;
256242 void *Argument;
257243
258244public:
259245 CancellationNotificationStatusRecord (FunctionType *fn, void *arg)
260- : TaskStatusRecord(TaskStatusRecordKind::CancellationNotification),
261- Function (fn), Argument(arg) {}
246+ : TaskStatusRecord(TaskStatusRecordKind::CancellationNotification),
247+ Function (fn), Argument(arg) {}
262248
263- void run () {
264- Function (Argument);
265- }
249+ void run () { Function (Argument); }
266250
267251 static bool classof (const TaskStatusRecord *record) {
268252 return record->getKind () == TaskStatusRecordKind::CancellationNotification;
@@ -279,20 +263,18 @@ class CancellationNotificationStatusRecord : public TaskStatusRecord {
279263// / subsequently used.
280264class EscalationNotificationStatusRecord : public TaskStatusRecord {
281265public:
282- using FunctionType = void (void *, JobPriority);
266+ using FunctionType = void (void *, JobPriority);
283267
284268private:
285- FunctionType * __ptrauth_swift_escalation_notification_function Function;
269+ FunctionType *__ptrauth_swift_escalation_notification_function Function;
286270 void *Argument;
287271
288272public:
289273 EscalationNotificationStatusRecord (FunctionType *fn, void *arg)
290- : TaskStatusRecord(TaskStatusRecordKind::EscalationNotification),
291- Function (fn), Argument(arg) {}
274+ : TaskStatusRecord(TaskStatusRecordKind::EscalationNotification),
275+ Function (fn), Argument(arg) {}
292276
293- void run (JobPriority newPriority) {
294- Function (Argument, newPriority);
295- }
277+ void run (JobPriority newPriority) { Function (Argument, newPriority); }
296278
297279 static bool classof (const TaskStatusRecord *record) {
298280 return record->getKind () == TaskStatusRecordKind::EscalationNotification;
0 commit comments