@@ -1387,7 +1387,6 @@ bool DefaultActorImpl::tryLock(bool asDrainer) {
13871387 dispatch_thread_override_info_s threadOverrideInfo;
13881388 threadOverrideInfo = swift_dispatch_thread_get_current_override_qos_floor ();
13891389 qos_class_t overrideFloor = threadOverrideInfo.override_qos_floor ;
1390- bool receivedOverride = false ;
13911390retry:;
13921391#else
13931392 SWIFT_TASK_DEBUG_LOG (" Thread attempting to jump onto %p, as drainer = %d" , this , asDrainer);
@@ -1406,10 +1405,6 @@ retry:;
14061405 // (4).
14071406 swift_release (this );
14081407
1409- if (receivedOverride) {
1410- // Reset any override as a result of contending for the actor lock.
1411- swift_dispatch_lock_override_end (overrideFloor);
1412- }
14131408 return false ;
14141409 }
14151410#endif
@@ -1429,7 +1424,6 @@ retry:;
14291424
14301425 (void ) swift_dispatch_thread_override_self (maxActorPriority);
14311426 overrideFloor = maxActorPriority;
1432- receivedOverride = true ;
14331427 goto retry;
14341428 }
14351429#endif /* SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION */
@@ -1447,6 +1441,7 @@ retry:;
14471441 // Taking the drain lock clears the max priority escalated bit because we've
14481442 // already represented the current max priority of the actor on the thread.
14491443 auto newState = oldState.withRunning ();
1444+ newState = newState.withoutEscalatedPriority ();
14501445
14511446 // This needs an acquire since we are taking a lock
14521447 if (_status ().compare_exchange_weak (oldState, newState,
@@ -1546,8 +1541,11 @@ bool DefaultActorImpl::unlock(bool forceUnlock)
15461541 }
15471542
15481543#if SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION
1549- // Reset any override on this thread as a result of this thread running
1550- // the actor. Only do this after we have reenqueued the actor
1544+ // Reset any asynchronous escalations we may have gotten on this thread
1545+ // after taking the drain lock.
1546+ //
1547+ // Only do this after we have reenqueued the actor so that we don't lose
1548+ // any "mojo" prior to the enqueue.
15511549 if (oldState.isMaxPriorityEscalated ()) {
15521550 swift_dispatch_lock_override_end ((qos_class_t ) oldState.getMaxPriority ());
15531551 }
0 commit comments