@@ -2205,6 +2205,7 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
22052205 _swift_task_clearCurrent ();
22062206}
22072207
2208+ #if !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
22082209namespace {
22092210// / Job that allows to use executor API to schedule a block of task-less
22102211// / synchronous code.
@@ -2233,6 +2234,7 @@ class IsolatedDeinitJob : public Job {
22332234 }
22342235};
22352236} // namespace
2237+ #endif
22362238
22372239SWIFT_CC (swift)
22382240static void swift_task_deinitOnExecutorImpl (void *object,
@@ -2253,8 +2255,12 @@ static void swift_task_deinitOnExecutorImpl(void *object,
22532255 return work (object); // 'return' forces tail call
22542256 }
22552257
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
22572262 if (newExecutor.isDefaultActor () && object == newExecutor.getIdentity ()) {
2263+ #endif
22582264 // Try to take the lock. This should always succeed, unless someone is
22592265 // running the actor using unsafe unowned reference.
22602266 if (asImpl (newExecutor.getDefaultActor ())->tryLock (false )) {
@@ -2284,7 +2290,7 @@ static void swift_task_deinitOnExecutorImpl(void *object,
22842290
22852291 // `work` is a synchronous function, it cannot call swift_task_switch()
22862292 // 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.
22882294 assert (newExecutor == trackingInfo.getActiveExecutor ());
22892295 assert (taskExecutor == trackingInfo.getTaskExecutor ());
22902296
@@ -2294,7 +2300,12 @@ static void swift_task_deinitOnExecutorImpl(void *object,
22942300 // Give up the current actor.
22952301 asImpl (newExecutor.getDefaultActor ())->unlock (true );
22962302 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
22972307 }
2308+ #if !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
22982309 }
22992310
23002311 auto currentTask = swift_task_getCurrent ();
@@ -2303,6 +2314,7 @@ static void swift_task_deinitOnExecutorImpl(void *object,
23032314
23042315 auto job = new IsolatedDeinitJob (priority, object, work);
23052316 swift_task_enqueue (job, newExecutor);
2317+ #endif
23062318}
23072319
23082320/* ****************************************************************************/
0 commit comments