Skip to content

Instantly share code, notes, and snippets.

@MrRooni
Created November 28, 2011 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrRooni/1402267 to your computer and use it in GitHub Desktop.
Save MrRooni/1402267 to your computer and use it in GitHub Desktop.
async'ing a dispatch_release
dispatch_queue_t some_worker_queue = dispatch_queue_create("some_worker_queue", DISPATCH_QUEUE_SERIAL);
dispatch_async(some_worker_queue, ^{
// Perform some work
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_release(some_worker_queue);
});
});
@SlaunchaMan
Copy link

Why not move the dispatch_release() call to the same scope as the dispatch_queue_create() call? It should be retained while it’s performing work.

@robrix
Copy link

robrix commented Nov 28, 2011

I would prefer this:

dispatch_queue_t queue = dispatch_queue_create("work", 0);

dispatch_async(queue ^{
    // work work work
});

dispatch_release(queue);

@MrRooni
Copy link
Author

MrRooni commented Nov 30, 2011

Answers in the form of a Twitter screen shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment