未验证 提交 3df212a3 编写于 作者: F FrankXMX 提交者: GitHub

增加线程名称,便于调试。 (#79)

* stage线程分配问题 #75

* 设置线程名称,在top时显示线程名,便于调试
上级 2cf120ab
......@@ -107,6 +107,9 @@ unsigned int Threadpool::add_threads(unsigned int threads)
LOG_WARN("Failed to create one thread\n");
break;
}
char tmp[16] = {};
snprintf(tmp,sizeof(tmp), "%s%u",name_.c_str(), i);
pthread_setname_np(pthread, tmp);
}
nthreads_ += i;
MUTEX_UNLOCK(&thread_mutex_);
......
......@@ -295,6 +295,8 @@ bool TimerStage::initialize()
int status = pthread_create(&timer_thread_id_, thread_attrs, &TimerStage::start_timer_thread, thread_args);
if (status != 0)
LOG_ERROR("failed to create timer thread: status=%d\n", status);
else
pthread_setname_np(timer_thread_id_, "TimerStage");
return (status == 0);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册