Skip to content

Commit 8dbddec

Browse files
Don't read current task executor to avoid extra access of the task-local storage.
1 parent 1b69068 commit 8dbddec

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,10 +2201,13 @@ 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+
2205+
// The only place where ExecutorTrackingInfo::getTaskExecutor() is
2206+
// called is in swift_task_switch(), but swift_task_switch() cannot be
2207+
// called from the synchronous code. So it does not really matter what is
2208+
// set in the ExecutorTrackingInfo::ActiveExecutor for the duration of the
2209+
// isolated deinit - it is unobservable anyway.
22042210
TaskExecutorRef taskExecutor = TaskExecutorRef::undefined();
2205-
if (ExecutorTrackingInfo *current = ExecutorTrackingInfo::current()) {
2206-
taskExecutor = current->getTaskExecutor();
2207-
}
22082211
trackingInfo.enterAndShadow(newExecutor, taskExecutor);
22092212

22102213
// Run the work.

0 commit comments

Comments
 (0)