From 955b8ae45979f4510dd7a17ec6672b040cf41e9a Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Tue, 8 Jun 2021 00:32:01 -0400 Subject: [PATCH] task: set the name of consumer threads so it is not "load_tracker" The default name of a newly constructed thread is apparently the name of the thread that created it. That's very misleading when there are a lot of TaskConsumer threads and they have nothing to do, so set the name of each TaskConsumer thread as soon as it is created. Signed-off-by: Zygo Blaxell --- lib/task.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/task.cc b/lib/task.cc index 794c92b..2fa257b 100644 --- a/lib/task.cc +++ b/lib/task.cc @@ -703,6 +703,9 @@ namespace crucible { // Detach thread so destructor doesn't call terminate m_thread->detach(); + // Set thread name so it isn't empty or the name of some other thread + DIE_IF_MINUS_ERRNO(pthread_setname_np(pthread_self(), "task_consumer")); + // It is now safe to access our own shared_ptr TaskConsumerPtr this_consumer = shared_from_this(); swap(this_consumer, tl_current_consumer);