@@ -776,12 +776,13 @@ void swift::_swift_taskGroup_detachChild(TaskGroup *group,
776
776
});
777
777
}
778
778
779
- // / Cancel all the child tasks that belong to `group`.
779
+ // / Cancel the task group and all the child tasks that belong to `group`.
780
780
// /
781
781
// / The caller must guarantee that this is called while holding the owning
782
782
// / task's status record lock.
783
- void swift::_swift_taskGroup_cancelAllChildren (TaskGroup *group) {
784
- assert (group->isCancelled () && " Expected task group to be cancelled when cancelling all child tasks." );
783
+ void swift::_swift_taskGroup_cancel (TaskGroup *group) {
784
+ (void ) group->statusCancel ();
785
+
785
786
// Because only the owning task of the task group can modify the
786
787
// child list of a task group status record, and it can only do so
787
788
// while holding the owning task's status record lock, we do not need
@@ -790,10 +791,10 @@ void swift::_swift_taskGroup_cancelAllChildren(TaskGroup *group) {
790
791
swift_task_cancel (childTask);
791
792
}
792
793
793
- // / Cancel all the child tasks that belong to `group`.
794
+ // / Cancel the task group and all the child tasks that belong to `group`.
794
795
// /
795
796
// / The caller must guarantee that this is called from the owning task.
796
- void swift::_swift_taskGroup_cancelAllChildren_unlocked (TaskGroup *group,
797
+ void swift::_swift_taskGroup_cancel_unlocked (TaskGroup *group,
797
798
AsyncTask *owningTask) {
798
799
// Early out. If there are no children, there's nothing to do. We can safely
799
800
// check this without locking, since this can only be concurrently mutated
@@ -802,7 +803,7 @@ void swift::_swift_taskGroup_cancelAllChildren_unlocked(TaskGroup *group,
802
803
return ;
803
804
804
805
withStatusRecordLock (owningTask, [&group](ActiveTaskStatus status) {
805
- _swift_taskGroup_cancelAllChildren (group);
806
+ _swift_taskGroup_cancel (group);
806
807
});
807
808
}
808
809
@@ -826,12 +827,7 @@ static void performCancellationAction(TaskStatusRecord *record) {
826
827
// under the synchronous control of the task that owns the group.
827
828
case TaskStatusRecordKind::TaskGroup: {
828
829
auto groupRecord = cast<TaskGroupTaskStatusRecord>(record);
829
- auto group = groupRecord->getGroup ();
830
- auto wasAlreadyCancelled = group->statusCancel ();
831
- if (wasAlreadyCancelled) {
832
- return ;
833
- }
834
- _swift_taskGroup_cancelAllChildren (group);
830
+ _swift_taskGroup_cancel (groupRecord->getGroup ());
835
831
return ;
836
832
}
837
833
0 commit comments