使用GCD创建高优先级的串行调度队列 [英] Create a high priority serial dispatch queue with GCD
本文介绍了使用GCD创建高优先级的串行调度队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建以高优先级运行的自定义串行队列?
How can I create a custom serial queue that runs at high priority?
现在我正在使用myQueue = dispatch_queue_create("com.MyApp.MyQueue", NULL);
,但这似乎不允许设置优先级吗?
Right now I'm using myQueue = dispatch_queue_create("com.MyApp.MyQueue", NULL);
but this doesn't seem to allow for setting a priority?
推荐答案
创建一个串行队列,然后使用dispatch_set_target_queue()
将其目标队列设置为高优先级队列.
Create a serial queue, then use dispatch_set_target_queue()
to set its target queue to the high priority queue.
方法如下:
dispatch_set_target_queue(myQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));
现在,myQueue
应该以高优先级顺序运行.
如果您想了解更多信息,请另一个SO答案.
Now myQueue
should run serially with high priority.
Here's another SO answer if you want to know more.
这篇关于使用GCD创建高优先级的串行调度队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文