Created
June 23, 2011 15:53
-
-
Save adamvduke/1042828 to your computer and use it in GitHub Desktop.
Testing dispatch_queue_create to see if it returns a unique queue for a given name
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> | |
int main (int argc, const char * argv[]) { | |
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
dispatch_queue_t queue1 = dispatch_queue_create("a_test_queue", NULL); | |
dispatch_queue_t queue2 = dispatch_queue_create("a_test_queue", NULL); | |
dispatch_async(queue1, ^{ | |
sleep(2); | |
NSLog(@"queue1 finishing the block" ); | |
}); | |
dispatch_async(queue2, ^{ | |
sleep(2); | |
NSLog(@"queue2 finishing the block"); | |
}); | |
BOOL same_queue = queue1 == queue2; | |
NSLog(@"%@", same_queue ? @"YES" : @"NO"); | |
dispatch_release(queue1); | |
dispatch_release(queue2); | |
[pool drain]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If someone else reach this code wondering the same question... The test returns "NO"