Index: src/OFExceptions.h ================================================================== --- src/OFExceptions.h +++ src/OFExceptions.h @@ -680,16 +680,10 @@ * An OFException indicating that joining the thread failed. */ @interface OFThreadJoinFailedException: OFException {} @end -/** - * 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 Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -979,25 +979,10 @@ string = [[OFString alloc] initWithFormat: @"Joining a thread of class %s failed! Most likely, another thread " @"already waits for the thread to join.", [class_ className]]; - return string; -} -@end - -/* FIXME: Not needed anymore? */ -@implementation OFThreadCanceledException -- (OFString*)string -{ - if (string != nil) - return string; - - 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 Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -131,21 +131,25 @@ - initWithDestructor: (void(*)(id))destructor { self = [super init]; - /* FIXME: Call destructor on Win32 */ if (!of_tlskey_new(&key, destructor)) { Class c = isa; [super dealloc]; @throw [OFInitializationFailedException newWithClass: c]; } return self; } -/* FIXME: Add dealloc! */ +- (void)dealloc +{ + of_tlskey_free(key); + + [super dealloc]; +} @end @implementation OFMutex + mutex { Index: src/threading.h ================================================================== --- src/threading.h +++ src/threading.h @@ -52,11 +52,10 @@ void *ret; if (pthread_join(thread, &ret)) return NO; - /* FIXME: Do we need a way to differentiate? */ return (ret != PTHREAD_CANCELED ? YES : NO); #else if (WaitForSingleObject(thread, INFINITE)) return NO; @@ -161,5 +160,15 @@ return (pthread_setspecific(key, p) ? NO : YES); #else return (TlsSetValue(key, p) ? YES : NO); #endif } + +static OF_INLINE BOOL +of_tlskey_free(of_tlskey_t key) +{ +#ifndef _WIN32 + return (pthread_key_delete(key) ? NO : YES); +#else + return (TlsFree(key) ? YES : NO); +#endif +}