Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9742] Thread's qualityOfService does not match one specific by OperationQueue.underlyingQueue (contrary to documentation) #3551

Open
swift-ci opened this issue Jan 24, 2019 · 0 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-9742
Radar None
Original Reporter martian111 (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 68b25b584799319d23bcb5720d61e3fa

Issue Description:

Given the following constants in a class:

private static let sharedQueue = DispatchQueue(label: "my-label", qos: .background)

private static let sharedURLSession: URLSession = {
    var queue = OperationQueue()
    queue.maxConcurrentOperationCount = 1
    //queue.qualityOfService = .background
    queue.underlyingQueue = sharedQueue
    return URLSession(configuration: .ephemeral, delegate: nil, delegateQueue: queue)
}()

When used, at runtime, the thread running completion handler of URLSessionTasks will have a qualityOfService set to -1 (default) instead of background. However, if I uncomment the line above setting the qualityOfService for the OperationQueue, then it works as expected (thread has correct qualityOfService).

Another way I tested was:

let dataTask = sharedURLSession.dataTask(with: request) { [weak self] (dataOpt, response, error) in
    do {
        assert(Thread.current.qualityOfService == .background, "This should run in background QoS thread!")
        ...
    } catch {
        ...
    }
}

The issue here is that this seems to directly contradict the documentation at:

https://developer.apple.com/documentation/foundation/operationqueue/1415344-underlyingqueue

which states:

The quality-of-service level set for the underlying dispatch queue overrides any value set for the operation queue's qualityOfService property.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant