Created
September 12, 2018 18:20
-
-
Save hadhi631/f88e54ff02f5d47da3c95b67ce743b17 to your computer and use it in GitHub Desktop.
RecLock
This file contains 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
@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