-
-
Save hramos/1482439 to your computer and use it in GitHub Desktop.
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
#import <Foundation/Foundation.h> | |
#define dispatch_if_available(queue, code) do{ \ | |
if(dispatch_async != NULL) { \ | |
dispatch_async(queue, ^(void) {\ | |
code\ | |
});\ | |
} else {\ | |
code\ | |
}\ | |
} while(0) | |
int main(int argc, char *argv[]) { | |
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init]; | |
dispatch_if_available(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), | |
int a = 0; | |
a++; | |
NSLog(@"a = %d", a); | |
); | |
[p release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment