Created
April 13, 2017 07:22
-
-
Save dreampiggy/92033875eb80471c70cefff8e43d227d to your computer and use it in GitHub Desktop.
GCD main queue Macro
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
#ifndef dispatch_main_sync_safe | |
#define dispatch_main_sync_safe(block)\ | |
if ([NSThread isMainThread]) {\ | |
block();\ | |
} else {\ | |
dispatch_sync(dispatch_get_main_queue(), block);\ | |
} | |
#endif | |
#ifndef dispatch_main_async_safe | |
#define dispatch_main_async_safe(block)\ | |
if ([NSThread isMainThread]) {\ | |
block();\ | |
} else {\ | |
dispatch_async(dispatch_get_main_queue(), block);\ | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment