@@ -23,10 +23,12 @@ #import "OFLockFailedException.h" #import "OFStillLockedException.h" #import "OFUnlockFailedException.h" @implementation OFMutex +@synthesize name = _name; + + (instancetype)mutex { return [[[self alloc] init] autorelease]; } @@ -42,10 +44,21 @@ _initialized = true; return self; } + +- (void)dealloc +{ + if (_initialized) + if (!of_mutex_free(&_mutex)) + @throw [OFStillLockedException exceptionWithLock: self]; + + [_name release]; + + [super dealloc]; +} - (void)lock { if (!of_mutex_lock(&_mutex)) @throw [OFLockFailedException exceptionWithLock: self]; @@ -60,35 +73,14 @@ { if (!of_mutex_unlock(&_mutex)) @throw [OFUnlockFailedException exceptionWithLock: self]; } -- (void)setName: (OFString*)name -{ - OF_SETTER(_name, name, true, 1) -} - -- (OFString*)name -{ - OF_GETTER(_name, true) -} - - (OFString*)description { if (_name == nil) return [super description]; return [OFString stringWithFormat: @"<%@: %@>", [self className], _name]; } - -- (void)dealloc -{ - if (_initialized) - if (!of_mutex_free(&_mutex)) - @throw [OFStillLockedException exceptionWithLock: self]; - - [_name release]; - - [super dealloc]; -} @end