Skip to content

Commit 656207c

Browse files
committed
[AsyncLet] ending an async let cancels the task
1 parent 78f0105 commit 656207c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

stdlib/public/Concurrency/AsyncLet.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,15 @@ SWIFT_CC(swift)
155155
static void swift_asyncLet_endImpl(AsyncLet *alet) {
156156
auto task = alet->getTask();
157157

158+
// Cancel the task as we exit the scope
159+
swift_task_cancel(task);
160+
158161
// Remove the child record from the parent task
159162
auto record = asImpl(alet)->getTaskRecord();
160163
swift_task_removeStatusRecord(record);
161164

165+
// TODO: we need to implicitly await either before the end or here somehow.
166+
162167
// and finally, release the task and free the async-let
163168
swift_release(task);
164169
}

0 commit comments

Comments
 (0)