@@ -776,12 +776,13 @@ void swift::_swift_taskGroup_detachChild(TaskGroup *group,
776776 });
777777}
778778
779- // / Cancel all the child tasks that belong to `group`.
779+ // / Cancel the task group and all the child tasks that belong to `group`.
780780// /
781781// / The caller must guarantee that this is called while holding the owning
782782// / 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+
785786 // Because only the owning task of the task group can modify the
786787 // child list of a task group status record, and it can only do so
787788 // while holding the owning task's status record lock, we do not need
@@ -790,10 +791,10 @@ void swift::_swift_taskGroup_cancelAllChildren(TaskGroup *group) {
790791 swift_task_cancel (childTask);
791792}
792793
793- // / Cancel all the child tasks that belong to `group`.
794+ // / Cancel the task group and all the child tasks that belong to `group`.
794795// /
795796// / 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,
797798 AsyncTask *owningTask) {
798799 // Early out. If there are no children, there's nothing to do. We can safely
799800 // check this without locking, since this can only be concurrently mutated
@@ -802,7 +803,7 @@ void swift::_swift_taskGroup_cancelAllChildren_unlocked(TaskGroup *group,
802803 return ;
803804
804805 withStatusRecordLock (owningTask, [&group](ActiveTaskStatus status) {
805- _swift_taskGroup_cancelAllChildren (group);
806+ _swift_taskGroup_cancel (group);
806807 });
807808}
808809
@@ -826,12 +827,7 @@ static void performCancellationAction(TaskStatusRecord *record) {
826827 // under the synchronous control of the task that owns the group.
827828 case TaskStatusRecordKind::TaskGroup: {
828829 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 ());
835831 return ;
836832 }
837833
0 commit comments