Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to dispatch_release()?

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?

like image 955
Rits Avatar asked Jan 30 '11 10:01

Rits


1 Answers

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.

like image 178
Ole Begemann Avatar answered Oct 22 '22 18:10

Ole Begemann