From 5f83c54f8ca2d5c1d0b0a7995d92b11a88c18f6b Mon Sep 17 00:00:00 2001 From: Bryce Wilson Date: Thu, 20 Nov 2025 11:14:03 +0900 Subject: [PATCH] [Concurrency] Set thread base priority when running escalated Tasks --- include/swift/Runtime/DispatchShims.h | 6 +++--- test/Concurrency/async_task_priority.swift | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/swift/Runtime/DispatchShims.h b/include/swift/Runtime/DispatchShims.h index 81020cd338c6f..062b291727c07 100644 --- a/include/swift/Runtime/DispatchShims.h +++ b/include/swift/Runtime/DispatchShims.h @@ -51,9 +51,9 @@ swift_dispatch_thread_override_self(qos_class_t override_qos) { static inline uint32_t swift_dispatch_thread_override_self_with_base(qos_class_t override_qos, qos_class_t base_qos) { - if (__builtin_available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)) { + if (__builtin_available(macOS 9998, iOS 9998, tvOS 9998, watchOS 9998, *)) { return dispatch_thread_override_self_with_base(override_qos, base_qos); - } else if (__builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)) { + } else if (__builtin_available(macOS 9998, iOS 9998, tvOS 9998, watchOS 9998, *)) { // If we don't have the ability to set our base qos correctly, at least set the override // We want to return 0 here because we have nothing to reset in this case (void) dispatch_thread_override_self(override_qos); @@ -64,7 +64,7 @@ swift_dispatch_thread_override_self_with_base(qos_class_t override_qos, qos_clas static inline void swift_dispatch_thread_reset_override_self(uint32_t opaque) { - if (__builtin_available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)) { + if (__builtin_available(macOS 9998, iOS 9998, tvOS 9998, watchOS 9998, *)) { dispatch_thread_reset_override_self(opaque); } } diff --git a/test/Concurrency/async_task_priority.swift b/test/Concurrency/async_task_priority.swift index b45b259f050e1..0b5e2ed74c635 100644 --- a/test/Concurrency/async_task_priority.swift +++ b/test/Concurrency/async_task_priority.swift @@ -322,15 +322,15 @@ actor Test { await task2.value // Escalate task2 which should be queued behind task1 on the actor } - // This test will only work properly on 27.0+ - if #available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *) { + // This test will only work properly if Dispatch supports lowering the base priority of a thread + if #available(macOS 9998, iOS 9998, tvOS 9998, watchOS 9998, *) { tests.test("Task escalation doesn't impact qos_class_self") { let task = Task(priority: .utility) { let initialQos = DispatchQoS( qosClass: DispatchQoS.QoSClass(rawValue: qos_class_self())!, relativePriority: 0) expectEqual(initialQos, DispatchQoS.utility) - let childTask = Task { + let innerTask = Task { let qosBeforeEscalate = DispatchQoS( qosClass: DispatchQoS.QoSClass(rawValue: qos_class_self())!, relativePriority: 0) @@ -353,7 +353,7 @@ actor Test { expectEqual(qosAfterYield, DispatchQoS.utility) } - await childTask.value + await innerTask.value } await task.value