Skip to content

Commit 5f83c54

Browse files
Bryce-MWktoso
authored andcommitted
[Concurrency] Set thread base priority when running escalated Tasks
1 parent b30f635 commit 5f83c54

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

include/swift/Runtime/DispatchShims.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ swift_dispatch_thread_override_self(qos_class_t override_qos) {
5151
static inline uint32_t
5252
swift_dispatch_thread_override_self_with_base(qos_class_t override_qos, qos_class_t base_qos) {
5353

54-
if (__builtin_available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)) {
54+
if (__builtin_available(macOS 9998, iOS 9998, tvOS 9998, watchOS 9998, *)) {
5555
return dispatch_thread_override_self_with_base(override_qos, base_qos);
56-
} else if (__builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)) {
56+
} else if (__builtin_available(macOS 9998, iOS 9998, tvOS 9998, watchOS 9998, *)) {
5757
// If we don't have the ability to set our base qos correctly, at least set the override
5858
// We want to return 0 here because we have nothing to reset in this case
5959
(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
6464

6565
static inline void
6666
swift_dispatch_thread_reset_override_self(uint32_t opaque) {
67-
if (__builtin_available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)) {
67+
if (__builtin_available(macOS 9998, iOS 9998, tvOS 9998, watchOS 9998, *)) {
6868
dispatch_thread_reset_override_self(opaque);
6969
}
7070
}

test/Concurrency/async_task_priority.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,15 @@ actor Test {
322322
await task2.value // Escalate task2 which should be queued behind task1 on the actor
323323
}
324324

325-
// This test will only work properly on 27.0+
326-
if #available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *) {
325+
// This test will only work properly if Dispatch supports lowering the base priority of a thread
326+
if #available(macOS 9998, iOS 9998, tvOS 9998, watchOS 9998, *) {
327327
tests.test("Task escalation doesn't impact qos_class_self") {
328328
let task = Task(priority: .utility) {
329329
let initialQos = DispatchQoS(
330330
qosClass: DispatchQoS.QoSClass(rawValue: qos_class_self())!,
331331
relativePriority: 0)
332332
expectEqual(initialQos, DispatchQoS.utility)
333-
let childTask = Task {
333+
let innerTask = Task {
334334
let qosBeforeEscalate = DispatchQoS(
335335
qosClass: DispatchQoS.QoSClass(rawValue: qos_class_self())!,
336336
relativePriority: 0)
@@ -353,7 +353,7 @@ actor Test {
353353
expectEqual(qosAfterYield, DispatchQoS.utility)
354354
}
355355

356-
await childTask.value
356+
await innerTask.value
357357
}
358358

359359
await task.value

0 commit comments

Comments
 (0)