diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7653bc39..3d05e9a4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -167,7 +167,10 @@ endif (USE_AMR_CODEC) target_link_libraries(rtphone ice_stack jrtplib g729_codec gsm_codec gsmhr_codec g722_codec srtp resiprocate - helper_lib audio_lib webrtc speexdsp + helper_lib + audio_lib + webrtc + speexdsp opus uuid ${OPENSSL_SSL} diff --git a/src/engine/helper/HL_Sync.cpp b/src/engine/helper/HL_Sync.cpp index 6534dd0a..9d59736c 100644 --- a/src/engine/helper/HL_Sync.cpp +++ b/src/engine/helper/HL_Sync.cpp @@ -48,7 +48,11 @@ long SyncHelper::increment(long *value) void ThreadHelper::setName(const std::string &name) { #if defined(TARGET_LINUX) - pthread_setname_np(pthread_self(), name.c_str()); + int retcode = pthread_setname_np(pthread_self(), name.c_str()); + if (retcode != 0) + { + std::cerr << "Failed to set Linux thread name" << std::endl; + } #endif } diff --git a/src/engine/helper/HL_ThreadPool.h b/src/engine/helper/HL_ThreadPool.h index bec1be2c..d82a7e9e 100644 --- a/src/engine/helper/HL_ThreadPool.h +++ b/src/engine/helper/HL_ThreadPool.h @@ -11,11 +11,12 @@ #include #include #include +#include "HL_Sync.h" class ThreadPool { public: - ThreadPool(size_t); + ThreadPool(size_t, const std::string&); template auto enqueue(F&& f, Args&&... args) -> std::future::type>; @@ -31,16 +32,18 @@ private: std::mutex queue_mutex; std::condition_variable condition; bool stop, pause; + std::string name; }; // the constructor just launches some amount of workers -inline ThreadPool::ThreadPool(size_t threads) - : stop(false), pause(false) +inline ThreadPool::ThreadPool(size_t threads, const std::string& name) + : stop(false), pause(false), name(name) { for(size_t i = 0;iname + std::to_string(i)); for(;;) { std::function task; bool task_assigned = false;