Create a high priority serial dispatch queue with GCD

前端 未结 3 1002
情书的邮戳
情书的邮戳 2020-12-09 09:44

How can I create a custom serial queue that runs at high priority?

Right now I\'m using myQueue = dispatch_queue_create(\"com.MyApp.MyQueue\", NULL); bu

3条回答
  •  北海茫月
    2020-12-09 09:53

    Create a serial queue, then use dispatch_set_target_queue() to set its target queue to the high priority queue.

    Here's how:

    dispatch_set_target_queue(myQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));
    

    Now myQueue should run serially with high priority. Here's another SO answer if you want to know more.

提交回复
热议问题