I am trying to understand what priority is going to be used to run dispatch blocks that are dispatched on a custom serial queue declared as:
dispatch_queue_t queue = dispatch_queue_create("com.purposeOfQueue.queue", DISPATCH_QUEUE_SERIAL);
So, here, I am only saying that "queue" is a serial queue. But, what priority is the system going to use for this queue. I know there's HIGH, DEFAULT, LOW, BACKGROUND.
I also know I could do this:
dispatch_set_target_queue(queue, DISPATCH_QUEUE_PRIORITY_DEFAULT);
Which would make it so the queue get a DEFAULT priority.
But if I just do what I showed above?
dispatch_queue_t queue = dispatch_queue_create("com.purposeOfQueue.queue", DISPATCH_QUEUE_SERIAL);
What priority is that going to use?
It's useful to note that from iOS 8 the creation of queues and their abilities have changed. You would use the following to get a serial queue with the lowest priority.
dispatch_queue_attr_t queueAttributes = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_BACKGROUND, 0);
self.queue = dispatch_queue_create("com.abc.myQueue", queueAttributes);
If you don't explicitly force a priority, it will use the "default" priority. This kinda goes right to the heart of the meaning of the word "default."
I believe that you can accomplish what you're looking for with:
dispatch_set_target_queue(queue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));
or DISPATCH_QUEUE_PRIORITY_LOW
as the case may be.
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