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)); } }