@@ -66,22 +66,20 @@ + threadWithObject: (id)obj { return [[[self alloc] initWithObject: obj] autorelease]; } -+ setObject: (OFObject*)obj - forTLSKey: (OFTLSKey*)key ++ (id)setObject: (OFObject*)obj + forTLSKey: (OFTLSKey*)key { id old = of_tlskey_get(key->key); if (!of_tlskey_set(key->key, [obj retain])) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; - [old release]; - - return self; + return [old autorelease]; } + (id)objectForTLSKey: (OFTLSKey*)key { return [[of_tlskey_get(key->key) retain] autorelease]; @@ -160,11 +158,11 @@ - (void)handleTermination { } -- start +- (void)start { if (running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException newWithClass: isa]; [self retain]; @@ -173,12 +171,10 @@ [self release]; @throw [OFThreadStartFailedException newWithClass: isa]; } running = OF_THREAD_RUNNING; - - return self; } - (id)join { if (running == OF_THREAD_NOT_RUNNING || !of_thread_join(thread)) @@ -301,33 +297,29 @@ } return self; } -- lock +- (void)lock { if (!of_mutex_lock(&mutex)) @throw [OFMutexLockFailedException newWithClass: isa]; - - return self; } - (BOOL)tryLock { return of_mutex_trylock(&mutex); } -- unlock +- (void)unlock { if (!of_mutex_unlock(&mutex)) @throw [OFMutexUnlockFailedException newWithClass: isa]; - - return self; } - (void)dealloc { of_mutex_free(&mutex); [super dealloc]; } @end