I’ve created a GCD queue like this:
dispatch_queue_t q = dispatch_queue_create("com.testcompany.myqueue", NULL);
When I dispatch tasks to that queue, it is way slower than simply executing the task on the main thread.
dispatch_async(q, ^(void) {
[self performHeavyCalculationAndUpdateUI];
});
My suspicion is that the queue has a very low priority by default.
How can I change the priority of this queue? Or is there something else I must do?
If you’re doing UIKit stuff, in your block that’s running on the secondary queue, dispatch the UI updates back to the main queue from within the secondary queue via:
Just dispatch the few lines that actually update the UI back to the main queue and you’ll see it’s not a matter of queue priorities, but rather just making sure that UI updates happen in main queue.