Created
June 10, 2016 20:32
-
-
Save mattconnolly/dc96b7ab415e9fe0b6827deec2be535e to your computer and use it in GitHub Desktop.
Dispatch_get_specific sees only the top queue
This file contains hidden or 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[]) { | |
@autoreleasepool { | |
dispatch_queue_t qa = dispatch_queue_create("a", DISPATCH_QUEUE_SERIAL); | |
dispatch_queue_t qb = dispatch_queue_create("b", DISPATCH_QUEUE_SERIAL); | |
static void* key = &key; | |
dispatch_queue_set_specific(qa, key, (void*)1, NULL); | |
NSLog(@"no queue. key = %p", dispatch_get_specific(key)); | |
dispatch_sync(qa, ^(){ | |
NSLog(@"queue a. key = %p", dispatch_get_specific(key)); | |
}); | |
dispatch_sync(qb, ^(){ | |
NSLog(@"queue b. key = %p", dispatch_get_specific(key)); | |
}); | |
dispatch_sync(qa, ^(){ | |
NSLog(@"queue a. key = %p", dispatch_get_specific(key)); | |
dispatch_sync(qb, ^(){ | |
NSLog(@"queue b on a. key = %p", dispatch_get_specific(key)); | |
}); | |
}); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment