- pthread_mutex_lock (&gui_notify_lock);
- ThreadLeaving (thread);
- pthread_mutex_unlock (&gui_notify_lock);
+ ThreadStartWithName* ts = (ThreadStartWithName*) arg;
+ void* (*thread_work)(void*) = ts->thread_work;
+ void* thread_arg = ts->arg;
+
+ /* name will be deleted by the default handler for GStaticPrivate, when the thread exits */
+
+ pthread_set_name (ts->name.c_str());
+
+ /* we don't need this object anymore */
+
+ delete ts;
+
+ /* actually run the thread's work function */
+
+ void* ret = thread_work (thread_arg);
+
+ /* cleanup */
+
+ pthread_mutex_lock (&thread_map_lock);
+
+ for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ++i) {
+ if (pthread_equal ((*i), pthread_self())) {
+ all_threads.erase (i);
+ break;
+ }
+ }
+
+ pthread_mutex_unlock (&thread_map_lock);
+
+ /* done */
+
+ return ret;