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?
Dispatch queues don't have a priority you can change.
You can change the target queue of your serial queues using the dispatch_set_target_queue
functions and use the DISPATCH_QUEUE_PRIORITY_HIGH
global queue. This just ensures that it will be scheduled before any other blocks enqueued on the queues with the default or low priority. Once your block starts executing it will not run faster or slower no matter what queue it was scheduled on.
Your problem most likely is the updating of your GUI, see Robert Ryans answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With