@@ -80,8 +80,17 @@ class alignas(2 * alignof(void*)) Job {
80
80
return Flags.getPriority ();
81
81
}
82
82
83
- // / Run this job.
84
- void run (ExecutorRef currentExecutor);
83
+ // / Given that we've fully established the job context in the current
84
+ // / thread, actually start running this job. To establish the context
85
+ // / correctly, call swift_job_run or runJobInExecutorContext.
86
+ void runInFullyEstablishedContext (ExecutorRef currentExecutor);
87
+
88
+ // / Given that we've fully established the job context in the
89
+ // / current thread, and that the job is a simple (non-task) job,
90
+ // / actually start running this job.
91
+ void runSimpleInFullyEstablishedContext (ExecutorRef currentExecutor) {
92
+ RunJob (this , currentExecutor);
93
+ }
85
94
};
86
95
87
96
// The compiler will eventually assume these.
@@ -173,7 +182,11 @@ class AsyncTask : public HeapObject, public Job {
173
182
assert (flags.isAsyncTask ());
174
183
}
175
184
176
- void run (ExecutorRef currentExecutor) {
185
+ // / Given that we've already fully established the job context
186
+ // / in the current thread, start running this task. To establish
187
+ // / the job context correctly, call swift_job_run or
188
+ // / runInExecutorContext.
189
+ void runInFullyEstablishedContext (ExecutorRef currentExecutor) {
177
190
ResumeTask (this , currentExecutor, ResumeContext);
178
191
}
179
192
@@ -941,11 +954,11 @@ static_assert(sizeof(AsyncTask) == 12 * sizeof(void*),
941
954
static_assert (alignof (AsyncTask) == 2 * alignof(void *),
942
955
"AsyncTask alignment is wrong");
943
956
944
- inline void Job::run (ExecutorRef currentExecutor) {
957
+ inline void Job::runInFullyEstablishedContext (ExecutorRef currentExecutor) {
945
958
if (auto task = dyn_cast<AsyncTask>(this ))
946
- task->run (currentExecutor);
959
+ task->runInFullyEstablishedContext (currentExecutor);
947
960
else
948
- RunJob ( this , currentExecutor);
961
+ runSimpleInFullyEstablishedContext ( currentExecutor);
949
962
}
950
963
951
964
// / An asynchronous context within a task. Generally contexts are
0 commit comments