@@ -15,15 +15,18 @@ */ #include "config.h" #import "OFMutex.h" +#import "OFString.h" #import "OFInitializationFailedException.h" #import "OFLockFailedException.h" #import "OFStillLockedException.h" #import "OFUnlockFailedException.h" + +#import "macros.h" @implementation OFMutex + (instancetype)mutex { return [[[self alloc] init] autorelease]; @@ -60,17 +63,37 @@ { if (!of_mutex_unlock(&mutex)) @throw [OFUnlockFailedException exceptionWithClass: [self class] lock: self]; } + +- (void)setName: (OFString*)name_ +{ + OF_SETTER(name, name_, YES, YES) +} + +- (OFString*)name +{ + OF_GETTER(name, YES) +} + +- (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 exceptionWithClass: [self class] lock: self]; + + [name release]; [super dealloc]; } @end