Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -118,11 +118,11 @@ @interface OFMutex: OFObject { #ifndef _WIN32 pthread_mutex_t mutex; #else - HANDLE mutex; + CRITICAL_SECTION mutex; #endif } /** * \return A new, autoreleased mutex. Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -185,40 +185,52 @@ { self = [super init]; #ifndef _WIN32 if (pthread_mutex_init(&mutex, NULL)) { -#else - if ((mutex = CreateMutex(NULL, FALSE, NULL)) == NULL) { -#endif Class c = isa; [self dealloc]; @throw [OFInitializationFailedException newWithClass: c]; } +#else + InitializeCriticalSection(&mutex); +#endif return self; } - lock { - /* FIXME: Add error-handling */ #ifndef _WIN32 + /* FIXME: Add error-handling */ pthread_mutex_lock(&mutex); #else - WaitForSingleObject(mutex, INFINITE); + EnterCriticalSection(&mutex); #endif return self; } - unlock { - /* FIXME: Add error-handling */ #ifndef _WIN32 + /* FIXME: Add error-handling */ pthread_mutex_unlock(&mutex); #else - ReleaseMutex(mutex); + LeaveCriticalSection(&mutex); #endif return self; } + +- (void)dealloc +{ +#ifndef _WIN32 + /* FIXME: Add error-handling */ + pthread_mutex_destroy(&mutex); +#else + DeleteCriticalSection(&mutex); +#endif + + [super dealloc]; +} @end