Created
September 9, 2011 08:27
-
-
Save steipete/1205760 to your computer and use it in GitHub Desktop.
dispatch_reentrant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
} |
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/dispatch_set_target_queue.3.html
http://developer.apple.com/library/iOS/#documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html
http://stackoverflow.com/questions/4942686/how-to-know-where-queue-am-i-main-queue-or-not
Seams this was fixed in iOS 5? Because the docs clearly differ, stating that this function returns the main queue if it is called on the main thread.
Am 17.09.2011 um 14:23 schrieb Peter Steinberger:
… http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/dispatch_set_target_queue.3.html
http://developer.apple.com/library/iOS/#documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html
http://stackoverflow.com/questions/4942686/how-to-know-where-queue-am-i-main-queue-or-not
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1205760
Where do you find this? Would be great if they changed this...
my exzerpt is from the documentation that comes with the latest Xcode 4.2 beta, so iOS 5 Beta 7.
sent from phone
Am 17.09.2011 um 15:09 schrieb Peter Steinbergerreply@reply.github.com:
… Where do you find this? Would be great if they changed this...
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1205760
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dispatch_get_current_queue, from the docs (iOS 5 Docs at least):
"When called from outside of the context of a submitted block, this function returns the main queue if the call is executed from the main thread. If the call is made from any other thread, this function returns the default concurrent queue."
Where is your excerpt from? I know I used a similar function in a project with the main queue and it worked.