@@ -17,13 +17,13 @@ #include "config.h" #import "OFMutex.h" #import "OFInitializationFailedException.h" -#import "OFMutexLockFailedException.h" -#import "OFMutexStillLockedException.h" -#import "OFMutexUnlockFailedException.h" +#import "OFLockFailedException.h" +#import "OFStillLockedException.h" +#import "OFUnlockFailedException.h" @implementation OFMutex + (instancetype)mutex { return [[[self alloc] init] autorelease]; @@ -42,21 +42,15 @@ initialized = YES; return self; } -- OF_initWithoutCreatingMutex -{ - return [super init]; -} - - (void)lock { if (!of_mutex_lock(&mutex)) - @throw [OFMutexLockFailedException - exceptionWithClass: [self class] - mutex: self]; + @throw [OFLockFailedException exceptionWithClass: [self class] + lock: self]; } - (BOOL)tryLock { return of_mutex_trylock(&mutex); @@ -63,22 +57,20 @@ } - (void)unlock { if (!of_mutex_unlock(&mutex)) - @throw [OFMutexUnlockFailedException - exceptionWithClass: [self class] - mutex: self]; + @throw [OFUnlockFailedException exceptionWithClass: [self class] + lock: self]; } - (void)dealloc { if (initialized) if (!of_mutex_free(&mutex)) - @throw [OFMutexStillLockedException + @throw [OFStillLockedException exceptionWithClass: [self class] - mutex: self]; + lock: self]; [super dealloc]; } @end -