Skip to content

Commit 1b69068

Browse files
Keep current task executor when taking fast path in isolated deinit
1 parent 2cb7e8d commit 1b69068

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2201,7 +2201,11 @@ static void swift_task_deinitOnExecutorImpl(void *object,
22012201
// but we don't have a tail call anyway, so this does not help much here.
22022202
// Always create new tracking info to keep code simple.
22032203
ExecutorTrackingInfo trackingInfo;
2204-
trackingInfo.enterAndShadow(newExecutor, TaskExecutorRef::undefined());
2204+
TaskExecutorRef taskExecutor = TaskExecutorRef::undefined();
2205+
if (ExecutorTrackingInfo *current = ExecutorTrackingInfo::current()) {
2206+
taskExecutor = current->getTaskExecutor();
2207+
}
2208+
trackingInfo.enterAndShadow(newExecutor, taskExecutor);
22052209

22062210
// Run the work.
22072211
work(object);
@@ -2210,6 +2214,7 @@ static void swift_task_deinitOnExecutorImpl(void *object,
22102214
// If it calls any synchronous API that may change executor inside
22112215
// tracking info, that API is also responsible for changing it back.
22122216
assert(newExecutor == trackingInfo.getActiveExecutor());
2217+
assert(taskExecutor == trackingInfo.getTaskExecutor());
22132218

22142219
// Leave the tracking frame
22152220
trackingInfo.leave();

0 commit comments

Comments
 (0)