Safe Way to Change NSOperation Priority

Is there a safe way to change the priority of an NSOperation that is already set to NSOperationQueue? If the operation has not started yet, there is no problem, but if it is already running, I get an NSInvalidArgumentException.

+5
source share
3 answers

You should not modify NSOperation after it has been queued. According to Apple Thread Programming Guide :

: , . , . , . , , , .

+11

Concurrency ,

For operations added to a queue, execution order is determined first by the
readiness of the queued operations and then by their relative priority. 
Readiness is determined by an operation’s dependencies on other operations, 
but the priority level is an attribute of the operation object itself. 
By default, all new operation objects have a "normal" priority, but you 
can increase or decrease that priority as needed by calling the object’s 
setQueuePriority: method.
+1

docs , , .

. , - ?

0

All Articles