Skip to content

Commit

Permalink
Use unspecified QoS in QueueScheduler when QoS is unspecified
Browse files Browse the repository at this point in the history
  • Loading branch information
jamieQ committed Oct 22, 2023
1 parent 74dce06 commit c71d84f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Scheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
33 changes: 33 additions & 0 deletions Tests/ReactiveSwiftTests/SchedulerSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,39 @@ 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))

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
))
}
}
}

Expand Down

0 comments on commit c71d84f

Please sign in to comment.