Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dispatch_once is not reentrant
#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;
}
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