@@ -24,10 +24,14 @@ #ifndef _WIN32 # include # include #endif + +#ifdef __HAIKU__ +# include +#endif #import "OFThread.h" #import "OFList.h" #import "OFDate.h" #import "OFSortedList.h" @@ -91,10 +95,23 @@ [thread release]; return 0; } + +static void +set_thread_name(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 +} @implementation OFThread #if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) @synthesize block; #endif @@ -286,10 +303,12 @@ [self release]; @throw [OFThreadStartFailedException exceptionWithClass: [self class] thread: self]; } + + set_thread_name(self); } - (id)join { if (running == OF_THREAD_NOT_RUNNING || !of_thread_join(thread)) @@ -299,10 +318,15 @@ running = OF_THREAD_NOT_RUNNING; return returnValue; } + +- copy +{ + return [self retain]; +} - (OFRunLoop*)runLoop { if (runLoop == nil) { OFRunLoop *tmp = [[OFRunLoop alloc] init]; @@ -311,10 +335,23 @@ [tmp release]; } return [[runLoop retain] autorelease]; } + +- (OFString*)name +{ + OF_GETTER(name, YES) +} + +- (void)setName: (OFString*)name_ +{ + OF_SETTER(name, name_, YES, YES) + + if (running == OF_THREAD_RUNNING) + set_thread_name(self); +} - (void)dealloc { if (running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException @@ -331,11 +368,6 @@ [returnValue release]; [runLoop release]; [super dealloc]; } - -- copy -{ - return [self retain]; -} @end