@@ -51,6 +51,7 @@ namespace swift {
51
51
52
52
class AsyncTask ;
53
53
class TaskGroup ;
54
+ class ActiveTaskStatus ;
54
55
55
56
// / Allocate task-local memory on behalf of a specific task,
56
57
// / not necessarily the current one. Generally this should only be
@@ -115,6 +116,63 @@ _swift_task_getDispatchQueueSerialExecutorWitnessTable() {
115
116
}
116
117
#endif
117
118
119
+ /* ************** Methods for Status records manipulation ******************/
120
+
121
+ // / Remove the status record from input task which may not be the current task.
122
+ // / This may be called asynchronously from the current task. After this call
123
+ // / returns, the record's memory can be freely modified or deallocated. The
124
+ // / record must be registered with the task. If it isn't, this function will
125
+ // / crash.
126
+ // /
127
+ // / This function also takes in a function_ref which is given the old
128
+ // / ActiveTaskStatus on the task and a reference to the new ActiveTaskStatus
129
+ // / that is to be set on the task that we are removing the record from. It may
130
+ // / modify the new ActiveTaskStatus that is to be set on the task. This function
131
+ // / may be called multiple times inside a RMW loop and must be therefore be
132
+ // / idempotent. The new status passed to `fn` is freshly derived from the
133
+ // / current status and does not include modifications made by previous runs
134
+ // / through the loop
135
+ SWIFT_CC (swift)
136
+ void removeStatusRecord (AsyncTask *task, TaskStatusRecord *record,
137
+ llvm::function_ref<void (ActiveTaskStatus, ActiveTaskStatus&)>fn);
138
+
139
+ // / Remove a status record from the current task. After this call returns,
140
+ // / the record's memory can be freely modified or deallocated.
141
+ // /
142
+ // / This must be called synchronously with the task.
143
+ // /
144
+ // / The given record need not be the last record added to
145
+ // / the task, but the operation may be less efficient if not.
146
+ SWIFT_CC (swift)
147
+ void removeStatusRecord (TaskStatusRecord *record);
148
+
149
+ // / Add a status record to the current task. This must be called synchronously
150
+ // / with the task.
151
+ // /
152
+ // / This function also takes in a function_ref which is given the old
153
+ // / ActiveTaskStatus on the task and a reference to the new ActiveTaskStatus
154
+ // / that is to be set on the task that we are adding the record to.
155
+ // /
156
+ // / This can be used by the function to
157
+ // / (1) to determine if the current status of the task permits adding the status
158
+ // / record
159
+ // / (2) modify the active task status that is to be set if needed
160
+ // /
161
+ // / If the function_ref returns false, the status record is not added to the
162
+ // / task. This function_ref may be called multiple times and must be idempotent.
163
+ // / The new status passed to `fn` is freshly derived from the current status and
164
+ // / does not include modifications made by previous runs through the loop
165
+ SWIFT_CC (swift)
166
+ bool addStatusRecord (TaskStatusRecord *record,
167
+ llvm::function_ref<bool (ActiveTaskStatus, ActiveTaskStatus&)> testAddRecord);
168
+
169
+ // / A helper function for updating a new child task that is created with
170
+ // / information from the parent or the group that it was going to be added to.
171
+ SWIFT_CC (swift)
172
+ void updateNewChildWithParentAndGroupState (AsyncTask *child,
173
+ ActiveTaskStatus parentStatus,
174
+ TaskGroup *group);
175
+
118
176
// ==== ------------------------------------------------------------------------
119
177
120
178
namespace {
@@ -851,39 +909,6 @@ inline bool AsyncTask::localValuePop() {
851
909
return _private ().Local .popValue (this );
852
910
}
853
911
854
- /* ************** Methods for Status records manipulation ******************/
855
-
856
- // / Remove a status record from a task. After this call returns,
857
- // / the record's memory can be freely modified or deallocated.
858
- // /
859
- // / This must be called synchronously with the task. The record must
860
- // / be registered with the task or else this may crash.
861
- // /
862
- // / The given record need not be the last record added to
863
- // / the task, but the operation may be less efficient if not.
864
- // /
865
- // / Returns false if the task has been cancelled.
866
- SWIFT_CC (swift)
867
- bool removeStatusRecord(TaskStatusRecord *record);
868
-
869
- // / Add a status record to a task. This must be called synchronously with the
870
- // / task.
871
- // /
872
- // / This function also takes in a function_ref which is given the task status of
873
- // / the task we're adding the record to, to determine if the current status of
874
- // / the task permits adding the status record. This function_ref may be called
875
- // / multiple times and must be idempotent.
876
- SWIFT_CC (swift)
877
- bool addStatusRecord(TaskStatusRecord *record,
878
- llvm::function_ref<bool (ActiveTaskStatus)> testAddRecord);
879
-
880
- // / A helper function for updating a new child task that is created with
881
- // / information from the parent or the group that it was going to be added to.
882
- SWIFT_CC (swift)
883
- void updateNewChildWithParentAndGroupState(AsyncTask *child,
884
- ActiveTaskStatus parentStatus,
885
- TaskGroup *group);
886
-
887
912
} // end namespace swift
888
913
889
914
#endif
0 commit comments