Is there a queue dictionary for a GCD queue

醉酒当歌 提交于 2019-12-06 05:19:24

问题


I am quite fond of the threadDictionary property in NSThread: very handy to store things with per-thread ownership.

Is there an equivalent dictionary for a GCD queue?


回答1:


You might want to look into dispatch_set_context/dispatch_get_context. Documentation here and here. You have to manage the context but it might be what you're looking for.




回答2:


If you can target iOS 5 and above, you can use dispatch_queue_get[set]_specific() which allows you to add dictionary-style (i.e. keyed) values to a queue. I can't find the document pages on them, strangely enough, but they are commented in queue.h



来源:https://stackoverflow.com/questions/11962850/is-there-a-queue-dictionary-for-a-gcd-queue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!