Skip to content

Instantly share code, notes, and snippets.

@adamvduke
Created June 23, 2011 15:53
Show Gist options
  • Save adamvduke/1042828 to your computer and use it in GitHub Desktop.
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
#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;
}
@dcordero
Copy link

If someone else reach this code wondering the same question... The test returns "NO"

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