@@ -42,10 +42,11 @@ #import "OFRunLoop.h" #import "OFList.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFAutoreleasePool.h" +#import "OFAutoreleasePool+Private.h" #ifdef _WIN32 # include #endif @@ -77,11 +78,11 @@ if (!of_tlskey_set(threadSelfKey, thread)) @throw [OFInitializationFailedException exceptionWithClass: [thread class]]; - objc_autoreleasePoolPush(); + thread->_pool = objc_autoreleasePoolPush(); /* * Nasty workaround for thread implementations which can't return a * value on join. */ @@ -94,18 +95,12 @@ [thread handleTermination]; thread->_running = OF_THREAD_WAITING_FOR_JOIN; -# ifdef OF_OBJFW_RUNTIME - /* - * As the values returned by objc_autoreleasePoolPush() in the ObjFW - * runtime are not actually pointers, but sequential numbers, 0 means - * we pop everything. - */ - objc_autoreleasePoolPop(0); -# endif + objc_autoreleasePoolPop(thread->_pool); + [OFAutoreleasePool OF_handleThreadTermination]; [thread release]; return 0; } @@ -233,18 +228,12 @@ [thread handleTermination]; thread->_running = OF_THREAD_WAITING_FOR_JOIN; } -# ifdef OF_OBJFW_RUNTIME - /* - * As the values returned by objc_autoreleasePoolPush() in the ObjFW - * runtime are not actually pointers, but sequential numbers, 0 means - * we pop everything. - */ - objc_autoreleasePoolPop(0); -# endif + objc_autoreleasePoolPop(thread->_pool); + [OFAutoreleasePool OF_handleThreadTermination]; [thread release]; of_thread_exit(); }