From 3a7c9d5d19974b1302c60066687986e15b46c0a0 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Thu, 28 Dec 2023 12:40:45 +0800 Subject: [PATCH] fix miss to_string --- src/ulib/system/thread.cpp | 6 +++++- src/ulib/system/thread_pool.cpp | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ulib/system/thread.cpp b/src/ulib/system/thread.cpp index 6e889d0..93dc884 100644 --- a/src/ulib/system/thread.cpp +++ b/src/ulib/system/thread.cpp @@ -1,5 +1,4 @@ #include "thread.h" -#include #include #include "ulib/log/log.h" #include "ulib/concorrency/countdown_latch.h" @@ -37,7 +36,12 @@ public: { Impl *impl = static_cast(obj); *impl->tid_ = GetTid(); +#if __APPLE__ pthread_setname_np(impl->thread_name_.c_str()); +#else + pthread_setname_np(&thread_, impl->thread_name_.c_str()); +#endif + impl->latch_.CountDown(); try { impl->func_(); diff --git a/src/ulib/system/thread_pool.cpp b/src/ulib/system/thread_pool.cpp index b4dbc1e..49a0864 100644 --- a/src/ulib/system/thread_pool.cpp +++ b/src/ulib/system/thread_pool.cpp @@ -1,4 +1,5 @@ #include "thread_pool.h" +#include namespace ulib { ThreadPool::ThreadPool(int max_thread_num, @@ -13,7 +14,7 @@ ThreadPool::ThreadPool(int max_thread_num, ULOG_ASSERT(max_thread_num_ > 0, "max_thread_num_ must be greater than 0"); workers_.reserve(max_thread_num_); for (int i = 0; i < init_thread_num; ++i) { - AddThread(thread_pool_name_ + std::to_string(i)); + AddThread(thread_pool_name_ + fmt::format("{}", i)); } }