@@ -124,34 +124,6 @@ _swift_task_getDispatchQueueSerialExecutorWitnessTable() {
124124
125125/* ************** Methods for Status records manipulation ******************/
126126
127- // / Remove the status record from input task which may not be the current task.
128- // / This may be called asynchronously from the current task. After this call
129- // / returns, the record's memory can be freely modified or deallocated. The
130- // / record must be registered with the task. If it isn't, this function will
131- // / crash.
132- // /
133- // / This function also takes in a function_ref which is given the old
134- // / ActiveTaskStatus on the task and a reference to the new ActiveTaskStatus
135- // / that is to be set on the task that we are removing the record from. It may
136- // / modify the new ActiveTaskStatus that is to be set on the task. This function
137- // / may be called multiple times inside a RMW loop and must be therefore be
138- // / idempotent. The new status passed to `fn` is freshly derived from the
139- // / current status and does not include modifications made by previous runs
140- // / through the loop
141- SWIFT_CC (swift)
142- void removeStatusRecord (AsyncTask *task, TaskStatusRecord *record,
143- llvm::function_ref<void (ActiveTaskStatus, ActiveTaskStatus&)>fn);
144-
145- // / Remove a status record from the current task. After this call returns,
146- // / the record's memory can be freely modified or deallocated.
147- // /
148- // / This must be called synchronously with the task.
149- // /
150- // / The given record need not be the last record added to
151- // / the task, but the operation may be less efficient if not.
152- SWIFT_CC (swift)
153- void removeStatusRecord (TaskStatusRecord *record);
154-
155127// / Add a status record to the input task.
156128// /
157129// / Clients can optionally pass in the status of the task if they have already
@@ -160,6 +132,12 @@ void removeStatusRecord(TaskStatusRecord *record);
160132// / perform. This status will be updated with the last status on the task prior
161133// / to updating it with the new status if the input function_ref allows so.
162134// /
135+ // / Clients can optionally pass in the status of the task if they have already
136+ // / done the load on it or if they require the oldStatus on the task prior to
137+ // / the atomic ActiveTaskStatus update that addStatusRecord will do. This status
138+ // / will be updated with the last status on the task prior to updating it with
139+ // / the new status if the input function_ref allows so.
140+ // /
163141// / This function also takes in a function_ref which is given the old
164142// / ActiveTaskStatus on the task and a reference to the new ActiveTaskStatus
165143// / that is to be set on the task that we are adding the record to.
@@ -195,6 +173,59 @@ SWIFT_CC(swift)
195173bool addStatusRecordToSelf (TaskStatusRecord *record, ActiveTaskStatus& taskStatus,
196174 llvm::function_ref<bool (ActiveTaskStatus, ActiveTaskStatus&)> testAddRecord);
197175
176+ // / Remove the status record from input task which may not be the current task.
177+ // / This may be called asynchronously from the current task. After this call
178+ // / returns, the record's memory can be freely modified or deallocated. The
179+ // / record must be registered with the task. If it isn't, this function will
180+ // / crash.
181+ // /
182+ // / The given record need not be the last record added to
183+ // / the task, but the operation may be less efficient if not.
184+ // /
185+ // / This function also takes in a function_ref which is given the old
186+ // / ActiveTaskStatus on the task and a reference to the new ActiveTaskStatus
187+ // / that is to be set on the task that we are removing the record from. It may
188+ // / modify the new ActiveTaskStatus that is to be set on the task. This function
189+ // / may be called multiple times inside a RMW loop and must be therefore be
190+ // / idempotent. The new status passed to `fn` is freshly derived from the
191+ // / current status and does not include modifications made by previous runs
192+ // / through the loop
193+ SWIFT_CC (swift)
194+ void removeStatusRecord (AsyncTask *task, TaskStatusRecord *record, ActiveTaskStatus& status,
195+ llvm::function_ref<void (ActiveTaskStatus, ActiveTaskStatus&)>fn = nullptr);
196+
197+ SWIFT_CC (swift)
198+ void removeStatusRecord (AsyncTask *task, TaskStatusRecord *record,
199+ llvm::function_ref<void (ActiveTaskStatus, ActiveTaskStatus&)>fn = nullptr);
200+
201+ // / Remove a status record from the current task. This must be called
202+ // / synchronously with the task.
203+ SWIFT_CC (swift)
204+ void removeStatusRecordFromSelf (TaskStatusRecord *record, ActiveTaskStatus &status,
205+ llvm::function_ref<void (ActiveTaskStatus, ActiveTaskStatus&)>fn = nullptr);
206+
207+ SWIFT_CC (swift)
208+ void removeStatusRecordFromSelf (TaskStatusRecord *record,
209+ llvm::function_ref<void (ActiveTaskStatus, ActiveTaskStatus&)>fn = nullptr);
210+
211+ // / Update the specified input status record while holding the status record
212+ // / lock of the task. The status record must already be registered with the
213+ // / task - if it isn't, this API provides no additional protections.
214+ // /
215+ // / This function also takes in a function_ref which is given the old
216+ // / ActiveTaskStatus on the task and a reference to the new ActiveTaskStatus
217+ // / that is to be set on the task when we are unlocking the task status record
218+ // / lock. It may modify the new ActiveTaskStatus that is to be set on the task.
219+ // / This function may be called multiple times inside a RMW loop and must be
220+ // / therefore be idempotent. The new status passed to `fn` is freshly derived
221+ // / from the current status and does not include modifications made by previous
222+ // / runs through the loop
223+ SWIFT_CC (swift)
224+ void updateStatusRecord (AsyncTask *task, TaskStatusRecord *record,
225+ llvm::function_ref<void ()>updateRecord,
226+ ActiveTaskStatus& status,
227+ llvm::function_ref<void(ActiveTaskStatus, ActiveTaskStatus&)>fn = nullptr);
228+
198229// / A helper function for updating a new child task that is created with
199230// / information from the parent or the group that it was going to be added to.
200231SWIFT_CC (swift)
@@ -842,7 +873,7 @@ inline void AsyncTask::flagAsRunning() {
842873 SWIFT_TASK_DEBUG_LOG (" [Dependency] %p->flagAsRunning() and remove dependencyRecord %p" ,
843874 this , dependencyRecord);
844875
845- removeStatusRecord (this , dependencyRecord, [&](ActiveTaskStatus oldStatus ,
876+ removeStatusRecord (this , dependencyRecord, oldStatus, [&](ActiveTaskStatus unused ,
846877 ActiveTaskStatus& newStatus) {
847878
848879#if SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION
@@ -863,7 +894,6 @@ inline void AsyncTask::flagAsRunning() {
863894 newStatus = newStatus.withoutEnqueued ();
864895 newStatus = newStatus.withoutTaskDependency ();
865896 });
866-
867897 this ->destroyTaskDependency (dependencyRecord);
868898
869899 adoptTaskVoucher (this );
0 commit comments