Skip to content

Commit b83d36b

Browse files
authored
[Concurrency] Fix DiscardingTaskGroup in SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL (swiftlang#63010)
1 parent 14ed022 commit b83d36b

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
@@ -1060,6 +1060,15 @@ static void _enqueueCompletedTask(NaiveTaskGroupQueue<ReadyQueueItem> *readyQueu
10601060
readyQueue->enqueue(readyItem);
10611061
}
10621062

1063+
/// This can only be used by a discarding task group;
1064+
/// Other groups must enqueue a complete Task to the ready queue.
1065+
static void _enqueueRawError(DiscardingTaskGroup* _Nonnull group,
1066+
NaiveTaskGroupQueue<ReadyQueueItem> *readyQueue,
1067+
SwiftError *error) {
1068+
auto readyItem = ReadyQueueItem::getRawError(group, error);
1069+
readyQueue->enqueue(readyItem);
1070+
}
1071+
10631072
// TaskGroup is locked upon entry and exit
10641073
void AccumulatingTaskGroup::enqueueCompletedTask(AsyncTask *completedTask, bool hadErrorResult) {
10651074
// Retain the task while it is in the queue; it must remain alive until
@@ -1233,6 +1242,7 @@ void DiscardingTaskGroup::offer(AsyncTask *completedTask, AsyncContext *context)
12331242
}
12341243

12351244
auto afterComplete = statusCompletePendingAssumeRelease();
1245+
(void)afterComplete; // silence "not used" warning
12361246
SWIFT_TASK_GROUP_DEBUG_LOG(this, "offer, either more pending tasks, or no waiting task, status:%s",
12371247
afterComplete.to_string(this).c_str());
12381248
}
@@ -1348,7 +1358,7 @@ void DiscardingTaskGroup::resumeWaitingTaskWithError(
13481358
// we can't just have the parent task set itself up as a waiter.
13491359
// But since it's what we're doing, we basically take the same
13501360
// path as we would if there wasn't a waiter.
1351-
enqueueCompletedTask(completedTask, hadErrorResult);
1361+
_enqueueRawError(this, &readyQueue, error);
13521362
return;
13531363

13541364
#else /* SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL */

0 commit comments

Comments
 (0)