@@ -29,10 +29,11 @@ #import "OFThread.h" #import "OFList.h" #import "OFDate.h" #import "OFSortedList.h" +#import "OFRunLoop.h" #import "OFAutoreleasePool.h" #ifdef _WIN32 # include #endif @@ -280,17 +281,12 @@ return nil; } - (void)handleTermination { - @synchronized (timersQueue) { - /* - * Make sure we don't run old timers when the thread is - * restarted. - */ - [timersQueue removeAllObjects]; - } + [runLoop release]; + runLoop = nil; } - (void)start { if (running == OF_THREAD_RUNNING) @@ -325,20 +321,20 @@ running = OF_THREAD_NOT_RUNNING; return returnValue; } -- (OFSortedList*)_timersQueue -{ - if (timersQueue == nil) { - OFSortedList *tmp = [[OFSortedList alloc] init]; - - if (!of_atomic_cmpswap_ptr((void**)&timersQueue, nil, tmp)) - [tmp release]; - } - - return [[timersQueue retain] autorelease]; +- (OFRunLoop*)runLoop +{ + return [[runLoop retain] autorelease]; +} + +- (void)_setRunLoop: (OFRunLoop*)runLoop_ +{ + OFRunLoop *old = runLoop; + runLoop = [runLoop_ retain]; + [old release]; } - (void)dealloc { if (running == OF_THREAD_RUNNING) @@ -353,11 +349,10 @@ if (running == OF_THREAD_WAITING_FOR_JOIN) of_thread_detach(thread); [object release]; [returnValue release]; - [timersQueue release]; [super dealloc]; } - copy