Skip to content

Instantly share code, notes, and snippets.

@hadhi631
Created September 12, 2018 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadhi631/f88e54ff02f5d47da3c95b67ce743b17 to your computer and use it in GitHub Desktop.
Save hadhi631/f88e54ff02f5d47da3c95b67ce743b17 to your computer and use it in GitHub Desktop.
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