fix miss to_string
Some checks failed
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Failing after 48s
linux-x64-gcc / linux-gcc (push) Failing after 56s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Failing after 1m4s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Failing after 1m26s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Failing after 1m8s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Failing after 52s
linux-mips64-gcc / linux-gcc-mips64el (push) Failing after 1m1s

This commit is contained in:
tqcq 2023-12-28 12:40:45 +08:00
parent 7c60170516
commit 3a7c9d5d19
2 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,4 @@
#include "thread.h"
#include <climits>
#include <pthread.h>
#include "ulib/log/log.h"
#include "ulib/concorrency/countdown_latch.h"
@ -37,7 +36,12 @@ public:
{
Impl *impl = static_cast<Impl *>(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_();

View File

@ -1,4 +1,5 @@
#include "thread_pool.h"
#include <fmt/format.h>
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));
}
}