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