Skip to content

Instantly share code, notes, and snippets.

@steipete
Created September 9, 2011 08:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save steipete/1205760 to your computer and use it in GitHub Desktop.
Save steipete/1205760 to your computer and use it in GitHub Desktop.
dispatch_reentrant
// checks if already in current queue, prevents deadlock
void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_block_t block) {
if (dispatch_get_current_queue() == queue) {
block();
}else {
dispatch_sync(queue, block);
}
}
@myell0w
Copy link

myell0w commented Sep 17, 2011 via email

@steipete
Copy link
Author

Where do you find this? Would be great if they changed this...

@myell0w
Copy link

myell0w commented Sep 17, 2011 via email

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