Alex Rivera | Logout

Reorder NSOperationQueue

Asked 2010-01-26T18:14:11.267
9

I'm looking for a way to reorder an NSOperationQueue.

I could cancel all the operations and toss them back in using the order I want, but I was hoping for something a little bit cleaner. Any thoughts?

Edit
Report

1 Answer

21

The major difference between NSOperationQueue and the underlying GCD queues is that NSOperations support dependencies between operations. NSOperationQueue will not schedule an operation until all of its dependencies have completed. Of the available operations, the highest priority operation is chosen to run next.

Since the operation queue may run several operations simultaneously (according to maxConcurrentOperations), there is not strict sense of order on the queue. You would be much better off using the dependencies API or changing operation prorities.

I believe that you can change dependencies and priorities after adding an operation to the queue.

answered 2010-01-26T18:36:15.507

Your Answer