Skip to content

Commit 5368235

Browse files
authored
[Concurrency] Fix DiscardingTaskGroup in TASK_TO_THREAD (#63009)
1 parent 943d1b8 commit 5368235

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

stdlib/public/Concurrency/TaskGroup.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,15 @@ static void _enqueueCompletedTask(NaiveTaskGroupQueue<ReadyQueueItem> *readyQueu
10531053
readyQueue->enqueue(readyItem);
10541054
}
10551055

1056+
/// This can only be used by a discarding task group;
1057+
/// Other groups must enqueue a complete Task to the ready queue.
1058+
static void _enqueueRawError(DiscardingTaskGroup* _Nonnull group,
1059+
NaiveTaskGroupQueue<ReadyQueueItem> *readyQueue,
1060+
SwiftError *error) {
1061+
auto readyItem = ReadyQueueItem::getRawError(group, error);
1062+
readyQueue->enqueue(readyItem);
1063+
}
1064+
10561065
// TaskGroup is locked upon entry and exit
10571066
void AccumulatingTaskGroup::enqueueCompletedTask(AsyncTask *completedTask, bool hadErrorResult) {
10581067
// Retain the task while it is in the queue; it must remain alive until
@@ -1226,6 +1235,7 @@ void DiscardingTaskGroup::offer(AsyncTask *completedTask, AsyncContext *context)
12261235
}
12271236

12281237
auto afterComplete = statusCompletePendingAssumeRelease();
1238+
(void)afterComplete; // silence "not used" warning
12291239
SWIFT_TASK_GROUP_DEBUG_LOG(this, "offer, either more pending tasks, or no waiting task, status:%s",
12301240
afterComplete.to_string(this).c_str());
12311241
}
@@ -1341,7 +1351,7 @@ void DiscardingTaskGroup::resumeWaitingTaskWithError(
13411351
// we can't just have the parent task set itself up as a waiter.
13421352
// But since it's what we're doing, we basically take the same
13431353
// path as we would if there wasn't a waiter.
1344-
enqueueCompletedTask(completedTask, hadErrorResult);
1354+
_enqueueRawError(this, &readyQueue, error);
13451355
return;
13461356

13471357
#else /* SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL */

0 commit comments

Comments
 (0)