@@ -454,6 +454,8 @@ static TaskGroup *asAbstract(TaskGroupImpl *group) {
454
454
// Initializes into the preallocated _group an actual TaskGroupImpl.
455
455
SWIFT_CC (swift)
456
456
static void swift_taskGroup_initializeImpl(TaskGroup *group, const Metadata *T) {
457
+ SWIFT_TASK_DEBUG_LOG (" creating task group = %p" , group);
458
+
457
459
TaskGroupImpl *impl = new (group) TaskGroupImpl (T);
458
460
auto record = impl->getTaskRecord ();
459
461
assert (impl == record && " the group IS the task record" );
@@ -472,8 +474,7 @@ static void swift_taskGroup_initializeImpl(TaskGroup *group, const Metadata *T)
472
474
SWIFT_CC (swift)
473
475
static void swift_taskGroup_attachChildImpl(TaskGroup *group,
474
476
AsyncTask *child) {
475
- SWIFT_TASK_DEBUG_LOG (" attach child task = %p to group = %p\n " ,
476
- child, group);
477
+ SWIFT_TASK_DEBUG_LOG (" attach child task = %p to group = %p" , child, group);
477
478
478
479
// The counterpart of this (detachChild) is performed by the group itself,
479
480
// when it offers the completed (child) task's value to a waiting task -
@@ -490,11 +491,17 @@ static void swift_taskGroup_destroyImpl(TaskGroup *group) {
490
491
}
491
492
492
493
void TaskGroupImpl::destroy () {
494
+ SWIFT_TASK_DEBUG_LOG (" destroying task group = %p" , this );
495
+
493
496
// First, remove the group from the task and deallocate the record
494
497
swift_task_removeStatusRecord (getTaskRecord ());
495
498
496
- // By the time we call destroy, all tasks inside the group must have been
497
- // awaited on already; We handle this on the swift side.
499
+ // No need to drain our queue here, as by the time we call destroy,
500
+ // all tasks inside the group must have been awaited on already.
501
+ // This is done in Swift's withTaskGroup function explicitly.
502
+
503
+ // destroy the group's storage
504
+ this ->~TaskGroupImpl ();
498
505
}
499
506
500
507
// =============================================================================
@@ -566,7 +573,7 @@ void TaskGroupImpl::offer(AsyncTask *completedTask, AsyncContext *context) {
566
573
bool hadErrorResult = false ;
567
574
auto errorObject = asyncContextPrefix->errorResult ;
568
575
if (errorObject) {
569
- // instead we need to enqueue this result:
576
+ // instead, we need to enqueue this result:
570
577
hadErrorResult = true ;
571
578
}
572
579
0 commit comments