When to dispatch_release()?

一曲冷凌霜 提交于 2019-12-09 17:59:01

问题


I'm fairly new to GCD and was trying to find an answer to this. Assuming I have the following code:

dispatch_queue_t queue = dispatch_queue_create("queue", NULL);
dispatch_async(queue, ^{
    // do some stuff
});

Where in the code should I release the queue? Inside or outside the block?


回答1:


Outside the block. I'm fairly certain you don't have to wait for the async block to finish as GCD will retain the queue.



来源:https://stackoverflow.com/questions/4842460/when-to-dispatch-release

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