What is the correct way to release a GCD dispatch queue property?

后端 未结 4 928
耶瑟儿~
耶瑟儿~ 2021-02-18 19:18

I\'m using a dispatch_queue which is accessed through a property of its owner, like this:

@property (nonatomic, assign) dispatch_queue_t queue;

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-18 19:54

    One interesting thing about this is that if the blocks submitted to the queue reference the object that owns the queue (e.g. "self"), the object will not hit dealloc until all pending blocks in the queue are completed anyway.

    Here is a project that demonstrates this:

    https://github.com/joshrl/GDCQueueDeallocTest

提交回复
热议问题