Skip to content

Commit 7286220

Browse files
committed
alternate take on locking
1 parent c49bd0a commit 7286220

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

stdlib/public/Concurrency/TaskGroup.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,12 +1652,12 @@ static void swift_taskGroup_waitAllImpl(
16521652
SwiftError *bodyError,
16531653
ThrowingTaskFutureWaitContinuationFunction *resumeFunction,
16541654
AsyncContext *rawContext) {
1655+
auto group = asBaseImpl(_group);
1656+
group->lock();
1657+
16551658
auto waitingTask = swift_task_getCurrent();
16561659
waitingTask->ResumeTask = task_group_wait_resume_adapter;
16571660
waitingTask->ResumeContext = rawContext;
1658-
1659-
auto group = asBaseImpl(_group);
1660-
group->lock();
16611661
PollResult polled = group->waitAll(bodyError, waitingTask);
16621662

16631663
auto context = static_cast<TaskFutureWaitAsyncContext *>(rawContext);
@@ -1672,16 +1672,14 @@ static void swift_taskGroup_waitAllImpl(
16721672

16731673
switch (polled.status) {
16741674
case PollStatus::MustWait: {
1675-
group->unlock();
1676-
16771675
// The waiting task has been queued on the channel,
16781676
// there were pending tasks so it will be woken up eventually.
16791677
#ifdef __ARM_ARCH_7K__
1680-
return workaround_function_swift_taskGroup_waitAllImpl(
1678+
workaround_function_swift_taskGroup_waitAllImpl(
16811679
resultPointer, callerContext, _group, bodyError, resumeFunction, rawContext);
1682-
#else /* __ARM_ARCH_7K__ */
1683-
return;
16841680
#endif /* __ARM_ARCH_7K__ */
1681+
group->unlock();
1682+
return;
16851683
}
16861684

16871685
case PollStatus::Error: {

0 commit comments

Comments
 (0)