diff --git a/CHANGELOG.md b/CHANGELOG.md index 47c5cbd3b..b6fbd3cb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # master *Please add new entries at the top.* +1. Change `QueueScheduler` to use unspecified QoS when QoS parameter is defaulted 1. Add support for VisionOS (#875, kudos to @NachoSoto) 1. Fix minimum deployment target of iOS 11 in CocoaPods 1. Fix CI release git tag push trigger (#869, kudos to @p4checo) diff --git a/Sources/Scheduler.swift b/Sources/Scheduler.swift index b2de042ae..c845f4a7b 100644 --- a/Sources/Scheduler.swift +++ b/Sources/Scheduler.swift @@ -363,7 +363,7 @@ public final class QueueScheduler: DateScheduler { /// - targeting: (Optional) The queue on which this scheduler's work is /// targeted public convenience init( - qos: DispatchQoS = .default, + qos: DispatchQoS = .unspecified, name: String = "org.reactivecocoa.ReactiveSwift.QueueScheduler", targeting targetQueue: DispatchQueue? = nil ) { diff --git a/Tests/ReactiveSwiftTests/SchedulerSpec.swift b/Tests/ReactiveSwiftTests/SchedulerSpec.swift index 2e704f125..8f1dbd925 100644 --- a/Tests/ReactiveSwiftTests/SchedulerSpec.swift +++ b/Tests/ReactiveSwiftTests/SchedulerSpec.swift @@ -6,6 +6,9 @@ // Copyright (c) 2014 GitHub. All rights reserved. // +#if canImport(Darwin) +import Darwin.sys.qos +#endif import Dispatch import Foundation @@ -261,6 +264,45 @@ class SchedulerSpec: QuickSpec { // enough time to ensure that the first timer was actually cancelled. expect(count).toEventually(equal(timesToRun)) } + + it("should propagate QoS values by default") { + expect(scheduler.queue.qos).to(equal(.unspecified)) + + // qos_class_self() may not be available on non-Darwin + // platforms, and it's unclear if QoS propagation is + // implemented in an equivalent manner in such contexts, + // so we restrict runtime validation tests to Darwin. + #if canImport(Darwin) + let userInitiatedQueue = DispatchQueue( + label: "reactiveswift.tests.user-initiated", + qos: .userInitiated + ) + userInitiatedQueue.suspend() + + var initialQoS: qos_class_t? + var endQoS: qos_class_t? + + userInitiatedQueue.async { + initialQoS = qos_class_self() + + // scheduling should propagate QoS values by default + scheduler.schedule { + endQoS = qos_class_self() + } + } + + scheduler.queue.resume() + userInitiatedQueue.resume() + + expect(initialQoS).toEventuallyNot(beNil()) + expect(endQoS).toEventuallyNot(beNil()) + + expect(initialQoS).to(equal(QOS_CLASS_USER_INITIATED)) + expect(endQoS?.rawValue).to(beGreaterThanOrEqualTo( + initialQoS?.rawValue + )) + #endif // canImport(Darwin) + } } }