gpt4 book ai didi

objective-c - 使用 GCD 创建高优先级串行调度队列

转载 作者:太空狗 更新时间:2023-10-30 03:13:26 26 4
gpt4 key购买 nike

如何创建以高优先级运行的自定义串行队列?

现在我正在使用 myQueue = dispatch_queue_create("com.MyApp.MyQueue", NULL); 但这似乎不允许设置优先级?

最佳答案

创建一个串行队列,然后使用dispatch_set_target_queue()将其目标队列设置为高优先级队列。

方法如下:

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

现在 myQueue 应该以高优先级串行运行。这是 another SO answer如果你想了解更多。

关于objective-c - 使用 GCD 创建高优先级串行调度队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17690740/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com