Set priority for custom serial asynchronous queue

How to set high priority for created sequential asynchronous queue using GCD?

I looked at this Q & A , which suggests using dispatch_set_target_queue() and Pass High Priority Queue ( DISPATCH_QUEUE_PRIORITY_HIGH ), which is a parallel queue for a user sequential asynchronous queue.

I understand that this will lead to the simultaneous execution of all tasks in the Serial Queue. Do I understand correctly? If so, what is the alternative solution?

+6
source share
2 answers

Your turn will continue to be consistent. He will perform his tasks one at a time in one slot of a high priority, global parallel background queue. Once created, a serial queue cannot be "made parallel" by any means.

Similarly, if you create a parallel queue and you configure it for the target queue, it becomes serial.

All of this is described in this manual page .

+5
source

Prior to installing iOS 8, the target queue in the high priority queue is how you will achieve this. Your queue will remain consistent, although the target queue will be parallel.

Starting with version 8.0, there is another way:

 dispatch_queue_attr_t queueAttrs = dispatch_queue_attr_make_with_qos_class( DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INITIATED /* Same as DISPATCH_QUEUE_PRIORITY_HIGH */, 0 ); dispatch_queue_t queue = dispatch_queue_create("myqueue",queueAttrs); 
+6
source

Source: https://habr.com/ru/post/976215/


All Articles