Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -75,16 +75,21 @@ OFMutableDictionary *_threadDictionary; @private OFString *_Nullable _name; } -#ifdef OF_HAVE_BLOCKS +/*! + * The name for the thread to use when starting it. + */ +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *name; + +# ifdef OF_HAVE_BLOCKS /*! * The block to execute in the thread. */ @property (readonly, nonatomic) of_thread_block_t threadBlock; -#endif +# endif /*! * @brief Creates a new thread. * * @return A new, autoreleased thread @@ -200,24 +205,10 @@ * * @return The run loop for the thread */ - (OFRunLoop *)runLoop; -/*! - * @brief Returns the name of the thread or `nil` if none has been set. - * - * @return The name of the thread or nil if none has been set - */ -- (nullable OFString *)name; - -/*! - * @brief Sets the name for the thread. - * - * @param name The name for the thread - */ -- (void)setName: (nullable OFString *)name; - /*! * @brief Returns the priority of the thread. * * This is a value between -1.0 (meaning lowest priority that still schedules) * and +1.0 (meaning highest priority that still allows getting preempted) Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -126,10 +126,11 @@ } #endif @implementation OFThread #ifdef OF_HAVE_THREADS +@synthesize name = _name; # ifdef OF_HAVE_BLOCKS @synthesize threadBlock = _threadBlock; # endif + (void)initialize @@ -349,13 +350,13 @@ [self release]; @throw [OFThreadStartFailedException exceptionWithThread: self]; } if (_name != nil) - of_thread_set_name(_thread, [_name UTF8String]); + of_thread_set_name([_name UTF8String]); else - of_thread_set_name(_thread, class_getName([self class])); + of_thread_set_name(class_getName([self class])); } - (id)join { if (_running == OF_THREAD_NOT_RUNNING || !of_thread_join(_thread)) @@ -388,26 +389,10 @@ # endif return _runLoop; } -- (OFString *)name -{ - return [[_name copy] autorelease]; -} - -- (void)setName: (OFString *)name -{ - OFString *old = name; - _name = [name copy]; - [old release]; - - if (_running == OF_THREAD_RUNNING) - of_thread_set_name(_thread, (_name != nil - ? [_name UTF8String] : class_getName([self class]))); -} - - (float)priority { return _attr.priority; } Index: src/threading.h ================================================================== --- src/threading.h +++ src/threading.h @@ -98,11 +98,11 @@ #endif extern bool of_thread_attr_init(of_thread_attr_t *attr); extern bool of_thread_new(of_thread_t *thread, void (*function)(id), id object, const of_thread_attr_t *attr); -extern void of_thread_set_name(of_thread_t thread, const char *name); +extern void of_thread_set_name(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_FUNC of_thread_exit(void); extern void of_once(of_once_t *control, void (*func)(void)); extern bool of_tlskey_new(of_tlskey_t *key); Index: src/threading_pthread.m ================================================================== --- src/threading_pthread.m +++ src/threading_pthread.m @@ -173,14 +173,14 @@ OF_UNREACHABLE } void -of_thread_set_name(of_thread_t thread, const char *name) +of_thread_set_name(const char *name) { #if defined(OF_HAIKU) - rename_thread(get_pthread_thread_id(thread), name); + rename_thread(find_thread(NULL), name); #elif defined(HAVE_PTHREAD_SET_NAME_NP) pthread_set_name_np(pthread_self(), name); #elif defined(HAVE_PTHREAD_SETNAME_NP) # if defined(OF_MACOS) || defined(OF_IOS) pthread_setname_np(name); Index: src/threading_winapi.m ================================================================== --- src/threading_winapi.m +++ src/threading_winapi.m @@ -84,11 +84,11 @@ OF_UNREACHABLE } void -of_thread_set_name(of_thread_t thread, const char *name) +of_thread_set_name(const char *name) { } bool of_tlskey_new(of_tlskey_t *key)