获取当前的调度队列? [英] Get current dispatch queue?

查看:96
本文介绍了获取当前的调度队列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个方法应该支持从任何队列调用,并且应该期望。它在后台线程本身运行一些代码,然后在它返回一个值的块参数时使用dispatch_get_main_queue。我不希望它强制它进入主队列,如果不是它进入方法时。有没有办法获得指向当前调度队列的指针?

I have a method which should support being called from any queue, and should expect to. It runs some code in a background thread itself, and then uses dispatch_get_main_queue when it returns a value to it's block argument. I don't want it to force it onto the main queue if it wasn't when it entered the method. Is there a way to get a pointer to the current dispatch queue?

推荐答案

你可以选择 dispatch_get_current_queue(),但iOS 6.1 SDK使用这些免责声明定义此API:

You do have the option of "dispatch_get_current_queue()", however the iOS 6.1 SDK defines this API with these disclaimers:

建议仅用于调试和记录目的:

此功能是已弃用,将在以后的版本中删除。

如果您希望代码能够面向未来,可以考虑使用其他相关问题

这篇关于获取当前的调度队列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆