Kob*_*ski 1 iphone debugging multithreading grand-central-dispatch
我正在努力解决我的GCD代码中的死锁问题.然后我dispatch_debug在头文件中看到了这个函数<dispatch/object.h>.
/*!
* @function dispatch_debug
*
* @abstract
* Programmatically log debug information about a dispatch object.
*
* @param object
* The object to introspect.
*
* @param message
* The message to log above and beyond the introspection.
*/
__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW __attribute__((__format__(printf,2,3)))
void
dispatch_debug(dispatch_object_t object, const char *message, ...);
Run Code Online (Sandbox Code Playgroud)
但我无法做任何事情.我希望它会打印出状态并锁定或类似的东西.
这是我如何使用它:
grabber_queue = dispatch_queue_create("com.unpaq.tvguideplus.grabber", NULL);
dispatch_debug(grabber_queue, "grabber queue");
Run Code Online (Sandbox Code Playgroud)
dispatch_debug
调试信息记录到控制台日志中.此信息可用作调试工具,以在调用dispatch_debug函数时查看调度对象的内部状态(当前引用计数,暂停计数等).
dispatch_debug将消息发送到syslog.所以,
grabber_queue = dispatch_queue_create("com.unpaq.tvguideplus.grabber", NULL);
dispatch_debug(grabber_queue, "grabber queue");
Run Code Online (Sandbox Code Playgroud)
此代码将在system.log中打印如下.
May 13 08:50:17 hostname exefile[53164]: com.unpaq.tvguideplus.grabber[0x6200e10] = {
xrefcnt = 0x1, refcnt = 0x1, suspend_cnt = 0x0, locked = 0, target =
com.apple.root.default-overcommit-priority[0x1af0700], width = 0x0, running = 0x0,
barrier = 0 }: grabber queueMay
Run Code Online (Sandbox Code Playgroud)
它不会出现在Xcode调试控制台中.您可以在iPhone模拟器上的/Applications/Utilities/Console.app system.log中找到,或者在iPhone,iPod touch和iPad上的Xcode组织器中看到.
顺便说一下,GCD是开源的.它通过libdispatch分发.dispatch_debug包含在src/object.c中.
| 归档时间: |
|
| 查看次数: |
1877 次 |
| 最近记录: |