Index: src/OFExceptions.h ================================================================== --- src/OFExceptions.h +++ src/OFExceptions.h @@ -685,5 +685,17 @@ /** * An OFException indicating that the thread has been canceled. */ @interface OFThreadCanceledException: OFException {} @end + +/** + * An OFException indicating that locking a mutex failed. + */ +@interface OFMutexLockFailedException: OFException {} +@end + +/** + * An OFException indicating that unlocking a mutex failed. + */ +@interface OFMutexUnlockFailedException: OFException {} +@end Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -994,8 +994,34 @@ string = [[OFString alloc] initWithFormat: @"The requested action cannot be performed because the thread of " @"class %s was canceled!", [class_ className]]; + return string; +} +@end + +@implementation OFMutexLockFailedException +- (OFString*)string +{ + if (string != nil) + return string; + + string = [[OFString alloc] initWithFormat: + @"A mutex could not be locked in class %s", [class_ className]]; + + return string; +} +@end + +@implementation OFMutexUnlockFailedException +- (OFString*)string +{ + if (string != nil) + return string; + + string = [[OFString alloc] initWithFormat: + @"A mutex could not be unlocked in class %s", [class_ className]]; + return string; } @end Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -165,27 +165,26 @@ return self; } - lock { - /* FIXME: Add error-handling */ - of_mutex_lock(&mutex); + if (!of_mutex_lock(&mutex)) + @throw [OFMutexLockFailedException newWithClass: isa]; return self; } - unlock { - /* FIXME: Add error-handling */ - of_mutex_unlock(&mutex); + if (!of_mutex_unlock(&mutex)) + @throw [OFMutexUnlockFailedException newWithClass: isa]; return self; } - (void)dealloc { - /* FIXME: Add error-handling */ of_mutex_free(&mutex); [super dealloc]; } @end