@@ -65,11 +65,11 @@ objc_thread_add(); #endif if (!of_tlskey_set(threadSelf, thread)) @throw [OFInitializationFailedException - newWithClass: [thread class]]; + exceptionWithClass: [thread class]]; /* * Nasty workaround for thread implementations which can't return a * value on join. */ @@ -107,11 +107,12 @@ { if (self != [OFThread class]) return; if (!of_tlskey_new(&threadSelf)) - @throw [OFInitializationFailedException newWithClass: self]; + @throw [OFInitializationFailedException + exceptionWithClass: self]; } + thread { return [[[self alloc] init] autorelease]; @@ -140,12 +141,12 @@ forTLSKey: (OFTLSKey*)key { id oldObject = of_tlskey_get(key->key); if (!of_tlskey_set(key->key, [object retain])) - @throw [OFInvalidArgumentException newWithClass: self - selector: _cmd]; + @throw [OFInvalidArgumentException exceptionWithClass: self + selector: _cmd]; [oldObject release]; } + (id)objectForTLSKey: (OFTLSKey*)key @@ -159,21 +160,21 @@ } + (void)sleepForTimeInterval: (double)seconds { if (seconds < 0) - @throw [OFOutOfRangeException newWithClass: self]; + @throw [OFOutOfRangeException exceptionWithClass: self]; #ifndef _WIN32 if (seconds > UINT_MAX) - @throw [OFOutOfRangeException newWithClass: self]; + @throw [OFOutOfRangeException exceptionWithClass: self]; sleep((unsigned int)seconds); usleep((useconds_t)rint((seconds - floor(seconds)) * 1000000)); #else if (seconds * 1000 > UINT_MAX) - @throw [OFOutOfRangeException newWithClass: self]; + @throw [OFOutOfRangeException exceptionWithClass: self]; Sleep((unsigned int)(seconds * 1000)); #endif } @@ -181,17 +182,17 @@ { double seconds = [date timeIntervalSinceNow]; #ifndef _WIN32 if (seconds > UINT_MAX) - @throw [OFOutOfRangeException newWithClass: self]; + @throw [OFOutOfRangeException exceptionWithClass: self]; sleep((unsigned int)seconds); usleep((useconds_t)rint((seconds - floor(seconds)) * 1000000)); #else if (seconds * 1000 > UINT_MAX) - @throw [OFOutOfRangeException newWithClass: self]; + @throw [OFOutOfRangeException exceptionWithClass: self]; Sleep((unsigned int)(seconds * 1000)); #endif } @@ -261,12 +262,12 @@ } #endif - (id)main { - @throw [OFNotImplementedException newWithClass: isa - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithClass: isa + selector: _cmd]; return nil; } - (void)handleTermination @@ -274,12 +275,12 @@ } - (void)start { if (running == OF_THREAD_RUNNING) - @throw [OFThreadStillRunningException newWithClass: isa - thread: self]; + @throw [OFThreadStillRunningException exceptionWithClass: isa + thread: self]; if (running == OF_THREAD_WAITING_FOR_JOIN) { of_thread_detach(thread); [returnValue release]; } @@ -286,33 +287,33 @@ [self retain]; if (!of_thread_new(&thread, call_main, self)) { [self release]; - @throw [OFThreadStartFailedException newWithClass: isa - thread: self]; + @throw [OFThreadStartFailedException exceptionWithClass: isa + thread: self]; } running = OF_THREAD_RUNNING; } - (id)join { if (running == OF_THREAD_NOT_RUNNING || !of_thread_join(thread)) - @throw [OFThreadJoinFailedException newWithClass: isa - thread: self]; + @throw [OFThreadJoinFailedException exceptionWithClass: isa + thread: self]; running = OF_THREAD_NOT_RUNNING; return returnValue; } - (void)dealloc { if (running == OF_THREAD_RUNNING) - @throw [OFThreadStillRunningException newWithClass: isa - thread: self]; + @throw [OFThreadStillRunningException exceptionWithClass: isa + thread: self]; /* * We should not be running anymore, but call detach in order to free * the resources. */ @@ -363,11 +364,11 @@ self = [super init]; @try { if (!of_tlskey_new(&key)) @throw [OFInitializationFailedException - newWithClass: isa]; + exceptionWithClass: isa]; initialized = YES; @synchronized (TLSKeys) { listObject = [TLSKeys appendObject: self]; @@ -419,11 +420,11 @@ self = [super init]; if (!of_mutex_new(&mutex)) { Class c = isa; [self release]; - @throw [OFInitializationFailedException newWithClass: c]; + @throw [OFInitializationFailedException exceptionWithClass: c]; } initialized = YES; return self; @@ -430,12 +431,12 @@ } - (void)lock { if (!of_mutex_lock(&mutex)) - @throw [OFMutexLockFailedException newWithClass: isa - mutex: self]; + @throw [OFMutexLockFailedException exceptionWithClass: isa + mutex: self]; } - (BOOL)tryLock { return of_mutex_trylock(&mutex); @@ -442,20 +443,21 @@ } - (void)unlock { if (!of_mutex_unlock(&mutex)) - @throw [OFMutexUnlockFailedException newWithClass: isa - mutex: self]; + @throw [OFMutexUnlockFailedException exceptionWithClass: isa + mutex: self]; } - (void)dealloc { if (initialized) if (!of_mutex_free(&mutex)) - @throw [OFMutexStillLockedException newWithClass: isa - mutex: self]; + @throw [OFMutexStillLockedException + exceptionWithClass: isa + mutex: self]; [super dealloc]; } @end @@ -470,11 +472,11 @@ self = [super init]; if (!of_condition_new(&condition)) { Class c = isa; [self release]; - @throw [OFInitializationFailedException newWithClass: c]; + @throw [OFInitializationFailedException exceptionWithClass: c]; } conditionInitialized = YES; return self; @@ -481,34 +483,37 @@ } - (void)wait { if (!of_condition_wait(&condition, &mutex)) - @throw [OFConditionWaitFailedException newWithClass: isa - condition: self]; + @throw [OFConditionWaitFailedException + exceptionWithClass: isa + condition: self]; } - (void)signal { if (!of_condition_signal(&condition)) - @throw [OFConditionSignalFailedException newWithClass: isa - condition: self]; + @throw [OFConditionSignalFailedException + exceptionWithClass: isa + condition: self]; } - (void)broadcast { if (!of_condition_broadcast(&condition)) - @throw [OFConditionBroadcastFailedException newWithClass: isa - condition: self]; + @throw [OFConditionBroadcastFailedException + exceptionWithClass: isa + condition: self]; } - (void)dealloc { if (conditionInitialized) if (!of_condition_free(&condition)) @throw [OFConditionStillWaitingException - newWithClass: isa - condition: self]; + exceptionWithClass: isa + condition: self]; [super dealloc]; } @end