Instantly share code, notes, and snippets.

Embed
What would you like to do?
RecLock
@implementation TestMutex {
NSRecursiveLock *recLock;
}
- (instancetype)init {
if (self = [super init]) {
// Initialize the mutex
recLock = [[NSRecursiveLock alloc] init];
}
return self;
}
- (void)process:(NSUInteger)value {
[recLock lock];
if (value != 0) {
--value;
[self process:value];
}
[recLock unlock];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment