@@ -1387,7 +1387,6 @@ bool DefaultActorImpl::tryLock(bool asDrainer) {
1387
1387
dispatch_thread_override_info_s threadOverrideInfo;
1388
1388
threadOverrideInfo = swift_dispatch_thread_get_current_override_qos_floor ();
1389
1389
qos_class_t overrideFloor = threadOverrideInfo.override_qos_floor ;
1390
- bool receivedOverride = false ;
1391
1390
retry:;
1392
1391
#else
1393
1392
SWIFT_TASK_DEBUG_LOG (" Thread attempting to jump onto %p, as drainer = %d" , this , asDrainer);
@@ -1406,10 +1405,6 @@ retry:;
1406
1405
// (4).
1407
1406
swift_release (this );
1408
1407
1409
- if (receivedOverride) {
1410
- // Reset any override as a result of contending for the actor lock.
1411
- swift_dispatch_lock_override_end (overrideFloor);
1412
- }
1413
1408
return false ;
1414
1409
}
1415
1410
#endif
@@ -1429,7 +1424,6 @@ retry:;
1429
1424
1430
1425
(void ) swift_dispatch_thread_override_self (maxActorPriority);
1431
1426
overrideFloor = maxActorPriority;
1432
- receivedOverride = true ;
1433
1427
goto retry;
1434
1428
}
1435
1429
#endif /* SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION */
@@ -1447,6 +1441,7 @@ retry:;
1447
1441
// Taking the drain lock clears the max priority escalated bit because we've
1448
1442
// already represented the current max priority of the actor on the thread.
1449
1443
auto newState = oldState.withRunning ();
1444
+ newState = newState.withoutEscalatedPriority ();
1450
1445
1451
1446
// This needs an acquire since we are taking a lock
1452
1447
if (_status ().compare_exchange_weak (oldState, newState,
@@ -1546,8 +1541,11 @@ bool DefaultActorImpl::unlock(bool forceUnlock)
1546
1541
}
1547
1542
1548
1543
#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.
1551
1549
if (oldState.isMaxPriorityEscalated ()) {
1552
1550
swift_dispatch_lock_override_end ((qos_class_t ) oldState.getMaxPriority ());
1553
1551
}
0 commit comments