Просмотр исходного кода

Give the worker threads a name.

The worker threads now have a name in the format "prob:__ wrkr:__" to make debugging easier. Thread names are limited to 16 bytes (15 + 1 null character).
Steven Engler 8 лет назад
Родитель
Сommit
ad3cdae4ba
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      worker.cc

+ 3 - 0
worker.cc

@@ -188,6 +188,9 @@ static void start_working(void)
 	wrkctrlstate.worker_thread = WT_NOT_RUNNING;
 	cerr << "Could not start worker thread\n";
     }
+    char thread_name[16];
+    snprintf(thread_name, sizeof(thread_name), "prob:%2d wrkr:%2d", wrkctrlstate.current_problem->problemid, wrkctrlstate.worker_id);
+    pthread_setname_np(wrkctrlstate.worker_thread, thread_name);
 }
 
 static void dpconn_event_cb(struct bufferevent *bev, short events,