The doc of NSOperationQueue.qualityOfService
says:
This property specifies the service level applied to operation objects added to the queue. If the operation object has an explicit service level set, that value is used instead.
It doesn't mention anything about the relative quality between operation and queue so any combination should work.
However, GCD
has some corresponding features whose docs say:
DISPATCH_BLOCK_ENFORCE_QOS_CLASS
Flag indicating that execution of a dispatch block object submitted to a queue should prefer the QOS class assigned to the block (resp. associated with the block at the time of submission) over the QOS class assigned to the queue, as long as doing so will not result in a lower QOS class.
If NSOperation
and NSOperationQueue
are built on top of GCD
— which I believe is true — it seems the restriction should also apply to them.
So if I add an NSOperation
with a lower qualityOfService
to an NSOperationQueue
will it run with its own lower qualityOfService
or the queue's higher qualityOfService
?
Thanks @das for pointing me to Foundation Release Notes for OS X v10.10.
Ignoring the operation dependency part, rules of QoS between
NSOperation
andNSOperationQueue
are exactly the same as that between dispatch block and dispatch queue — though @das points out "the QoS implementation of NSOperationQueue is not built on top of the GCD QoS block primitives" the rules are actually the same, that is to say,NSOperation
's QoS(if lower) will be raise toNSOperationQueue
's QoS. So my initial guess is correct. The doc ofNSOperationQueue.qualityOfService
is wrong:Here are the detailed explanation of QoS rules of
NSOperation
andNSOperationQueue
: