Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -67,12 +67,13 @@ # ifdef OF_HAVE_BLOCKS of_thread_block_t _threadBlock; # endif id _returnValue; OFRunLoop *_runLoop; - OFString *_name; OFMutableDictionary *_threadDictionary; +@private + OFString *_name; } # ifdef OF_HAVE_PROPERTIES # ifdef OF_HAVE_BLOCKS @property (copy) of_thread_block_t threadBlock; Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -34,14 +34,10 @@ #ifdef OF_HAVE_SCHED_YIELD # include #endif -#if defined(OF_HAVE_THREADS) && defined(__HAIKU__) -# include -#endif - #import "OFThread.h" #import "OFThread+Private.h" #import "OFRunLoop.h" #import "OFList.h" #import "OFDate.h" @@ -115,24 +111,10 @@ [thread release]; return 0; } - -static void -setThreadName(OFThread *thread) -{ -# ifdef __HAIKU__ - OFString *name = thread->_name; - - if (name == nil) - name = [thread className]; - - rename_thread(get_pthread_thread_id(thread->_thread), - [name UTF8String]); -# endif -} #endif @implementation OFThread #ifdef OF_HAVE_THREADS # if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) @@ -329,11 +311,14 @@ if (!of_thread_new(&_thread, callMain, self)) { [self release]; @throw [OFThreadStartFailedException exceptionWithThread: self]; } - setThreadName(self); + if (_name != nil) + of_thread_set_name(_thread, [_name UTF8String]); + else + of_thread_set_name(_thread, class_getName([self class])); } - (id)join { if (_running == OF_THREAD_NOT_RUNNING || !of_thread_join(_thread)) @@ -375,12 +360,17 @@ - (void)setName: (OFString*)name { OF_SETTER(_name, name, true, 1) - if (_running == OF_THREAD_RUNNING) - setThreadName(self); + if (_running == OF_THREAD_RUNNING) { + if (_name != nil) + of_thread_set_name(_thread, [_name UTF8String]); + else + of_thread_set_name(_thread, + class_getName([self class])); + } } - (void)dealloc { if (_running == OF_THREAD_RUNNING) Index: src/threading.h ================================================================== --- src/threading.h +++ src/threading.h @@ -85,10 +85,11 @@ # error of_thread_is_current not implemented! # error of_thread_current not implemented! #endif extern bool of_thread_new(of_thread_t *thread, id (*function)(id), id data); +extern void of_thread_set_name(of_thread_t thread, const char *name); extern bool of_thread_join(of_thread_t thread); extern bool of_thread_detach(of_thread_t thread); extern void OF_NO_RETURN of_thread_exit(void); extern void of_once(of_once_t *control, void (*func)(void)); extern bool of_mutex_new(of_mutex_t *mutex); Index: src/threading.m ================================================================== --- src/threading.m +++ src/threading.m @@ -21,10 +21,22 @@ #elif defined(_WIN32) # include "threading_winapi.m" #else # error No threads available! #endif + +#ifdef __HAIKU__ +# include +#endif + +void +of_thread_set_name(of_thread_t thread, const char *name) +{ +#ifdef __HAIKU__ + rename_thread(get_pthread_thread_id(thread), name); +#endif +} bool of_rmutex_new(of_rmutex_t *rmutex) { #ifdef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES