@@ -2205,6 +2205,7 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
2205
2205
_swift_task_clearCurrent ();
2206
2206
}
2207
2207
2208
+ #if !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
2208
2209
namespace {
2209
2210
// / Job that allows to use executor API to schedule a block of task-less
2210
2211
// / synchronous code.
@@ -2233,6 +2234,7 @@ class IsolatedDeinitJob : public Job {
2233
2234
}
2234
2235
};
2235
2236
} // namespace
2237
+ #endif
2236
2238
2237
2239
SWIFT_CC (swift)
2238
2240
static void swift_task_deinitOnExecutorImpl(void *object,
@@ -2253,8 +2255,12 @@ static void swift_task_deinitOnExecutorImpl(void *object,
2253
2255
return work (object); // 'return' forces tail call
2254
2256
}
2255
2257
2256
- // Optimize deallocation of the default actors
2258
+ #if SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
2259
+ // In this mode taking actor lock is the only possible implementation
2260
+ #else
2261
+ // Otherwise, it is an optimisation applied when deinitializing default actors
2257
2262
if (newExecutor.isDefaultActor () && object == newExecutor.getIdentity ()) {
2263
+ #endif
2258
2264
// Try to take the lock. This should always succeed, unless someone is
2259
2265
// running the actor using unsafe unowned reference.
2260
2266
if (asImpl (newExecutor.getDefaultActor ())->tryLock (false )) {
@@ -2284,7 +2290,7 @@ static void swift_task_deinitOnExecutorImpl(void *object,
2284
2290
2285
2291
// `work` is a synchronous function, it cannot call swift_task_switch()
2286
2292
// If it calls any synchronous API that may change executor inside
2287
- // tracking info, that API is also responsible for changing it back.
2293
+ // tracking info, that API is also responsible for changing it back.
2288
2294
assert (newExecutor == trackingInfo.getActiveExecutor ());
2289
2295
assert (taskExecutor == trackingInfo.getTaskExecutor ());
2290
2296
@@ -2294,7 +2300,12 @@ static void swift_task_deinitOnExecutorImpl(void *object,
2294
2300
// Give up the current actor.
2295
2301
asImpl (newExecutor.getDefaultActor ())->unlock (true );
2296
2302
return ;
2303
+ } else {
2304
+ #if SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
2305
+ assert (false && " Should not enqueue onto default actor in actor as locks model" );
2306
+ #endif
2297
2307
}
2308
+ #if !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
2298
2309
}
2299
2310
2300
2311
auto currentTask = swift_task_getCurrent ();
@@ -2303,6 +2314,7 @@ static void swift_task_deinitOnExecutorImpl(void *object,
2303
2314
2304
2315
auto job = new IsolatedDeinitJob (priority, object, work);
2305
2316
swift_task_enqueue (job, newExecutor);
2317
+ #endif
2306
2318
}
2307
2319
2308
2320
/* ****************************************************************************/
0 commit comments