I'm learning Swift concurrency and encountered this excerpt
“If you submit a task with a higher quality of service than the queue has, the queue’s level will increase. Not only that, but all the operations enqueued will also have their priority raised as well.”
As stated in the quote, I am trying to experiment it simulate that a queue with lower QoS will be increased if we submit a task with higher QoS. Here's my current code snippet:
let userInitiatedQueue = DispatchQueue.global(qos: .userInitiated)
let utilityQueue = DispatchQueue.global(qos: .utility)
userInitiatedQueue.async {
print("log from userInitiatedQueue")
utilityQueue.async {
// ❗️debugging at this point, checking `utilityQueue.qos` is still `.utility`
print("log from utilityQueue, it should increase the QoS")
}
}
// Submitting a `DispatchWorkItem` doesn't work either
let workItem = DispatchWorkItem(qos: .userInitiated) {
// ❗️debugging at this point, checking `utilityQueue.qos` is still `.utility`
print("log workItem from utilityQueue, it should increase the QoS")
}
utilityQueue.async(execute: workItem)
Could you provide a snippet that will prove the concept above?