Skip to content

Commit 4e459c6

Browse files
committed
Work around lack of qos_class_self in non-Darwin libdispatch
(cherry picked from commit fbc6237)
1 parent 38bfc9f commit 4e459c6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ JobPriority swift::swift_task_getCurrentThreadPriority() {
264264
if (isExecutingOnMainThread())
265265
return JobPriority::UserInitiated;
266266

267+
#if defined(__APPLE__)
267268
return static_cast<JobPriority>(qos_class_self());
269+
#else
270+
return JobPriority::Unspecified;
271+
#endif
268272
}
269273

270274
SWIFT_CC(swift)

test/Concurrency/Runtime/async.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
5656
asyncTests.test("GlobalDispatchQueue") {
5757
DispatchQueue.global(qos: .utility).async {
5858
async {
59+
#if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS))
60+
// Non-Darwin platforms currently lack qos_class_self().
5961
assert(Task.currentPriority == .utility)
62+
#endif
6063
}
6164
}
6265
sleep(1)

0 commit comments

Comments
 (0)