From 79a28df62597090da997a3f8c4624c938433e3fa Mon Sep 17 00:00:00 2001 From: Shuhao Wu Date: Fri, 2 Aug 2024 21:35:31 -0400 Subject: [PATCH] Set thread name with pthread API Fixes #94 --- .vscode/extensions.json | 3 ++- src/cactus_rt/thread.cc | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ba6e025..f4f3a9b 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,7 @@ { "recommendations": [ "ms-vscode.cpptools", - "llvm-vs-code-extensions.vscode-clangd" + "llvm-vs-code-extensions.vscode-clangd", + "cschlosser.doxdocgen" ] } diff --git a/src/cactus_rt/thread.cc b/src/cactus_rt/thread.cc index 91af9d7..8b25120 100644 --- a/src/cactus_rt/thread.cc +++ b/src/cactus_rt/thread.cc @@ -17,6 +17,8 @@ void* Thread::RunThread(void* data) { auto* thread = static_cast(data); thread->config_.scheduler->SetSchedAttr(); + pthread_setname_np(pthread_self(), thread->name_.c_str()); + thread->tracer_ = std::make_shared(thread->name_, thread->config_.tracer_config.queue_size); thread->tracer_->SetTid();