1616 * SPDX-License-Identifier: Apache-2.0
1717 * License-Filename: LICENSE
1818 */
19-
2019#include " olp/core/thread/ThreadPoolTaskScheduler.h"
20+ #include " olp/core/utils/Thread.h"
2121
2222#if defined(PORTING_PLATFORM_QNX)
2323#include < process.h>
3535#include " olp/core/logging/LogContext.h"
3636#include " olp/core/porting/platform.h"
3737#include " olp/core/thread/SyncQueue.h"
38- #include " olp/core/utils/WarningWorkarounds.h"
3938#include " thread/PriorityQueueExtended.h"
4039
4140namespace olp {
@@ -44,24 +43,6 @@ namespace thread {
4443namespace {
4544constexpr auto kLogTag = " ThreadPoolTaskScheduler" ;
4645
47- void SetCurrentThreadName (const std::string& thread_name) {
48- // Currently only supported for pthread users
49- OLP_SDK_CORE_UNUSED (thread_name);
50-
51- #if defined(PORTING_PLATFORM_MAC)
52- // Note that in Mac based systems the pthread_setname_np takes 1 argument
53- // only.
54- pthread_setname_np (thread_name.c_str ());
55- #elif defined(OLP_SDK_HAVE_PTHREAD_SETNAME_NP) // Linux, Android, QNX
56- // QNX allows 100 but Linux only 16 so select min value and apply for both.
57- // If maximum length is exceeded on some systems, e.g. Linux, the name is not
58- // set at all. So better truncate it to have at least the minimum set.
59- constexpr size_t kMaxThreadNameLength = 16u ;
60- std::string truncated_name = thread_name.substr (0 , kMaxThreadNameLength - 1 );
61- pthread_setname_np (pthread_self (), truncated_name.c_str ());
62- #endif // OLP_SDK_HAVE_PTHREAD_SETNAME_NP
63- }
64-
6546struct PrioritizedTask {
6647 TaskScheduler::CallFuncType function;
6748 uint32_t priority;
@@ -76,7 +57,7 @@ struct ComparePrioritizedTask {
7657
7758void SetExecutorName (size_t idx) {
7859 std::string thread_name = " OLPSDKPOOL_" + std::to_string (idx);
79- SetCurrentThreadName (thread_name);
60+ olp::utils::Thread:: SetCurrentThreadName (thread_name);
8061 OLP_SDK_LOG_INFO_F (kLogTag , " Starting thread '%s'" , thread_name.c_str ());
8162}
8263
0 commit comments