Created
April 20, 2012 02:04
-
-
Save boredzo/2425324 to your computer and use it in GitHub Desktop.
dispatch_once is not reentrant
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> | |
static void test(void); | |
int main(int argc, char **argv) { | |
@autoreleasepool { | |
test(); | |
NSLog(@"Test succeeded"); | |
} | |
return EXIT_SUCCESS; | |
} | |
static void test(void) { | |
static unsigned count = 0; | |
NSLog(@"Attempting test (%u)...", ++count); | |
static dispatch_once_t token; | |
dispatch_once(&token, ^{ | |
test(); | |
}); | |
--count; | |
} |
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
CC=clang | |
CFLAGS+=-std=c99 -g | |
LDFLAGS+=-framework Foundation | |
dispatch_once_reentrancy_test: dispatch_once_reentrancy_test.o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment