@@ -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