mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-05-16 20:32:43 -07:00
Thread names shortened to 15 characters to fit Posix norm.
Added get_current_thread_name()
This commit is contained in:
@@ -84,6 +84,13 @@ void set_current_thread_name(const char *thread_name)
|
||||
WindowsSetThreadName(::GetCurrentThread(), thread_name);
|
||||
}
|
||||
|
||||
void std::string get_current_thread_name() const
|
||||
{
|
||||
wchar_t *ptr = nullptr;
|
||||
::GetThreadDescription(::GetCurrentThread(), &ptr);
|
||||
return std::string((ptr == nullptr) ? "" : ptr);
|
||||
}
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
// posix
|
||||
@@ -102,6 +109,12 @@ void set_current_thread_name(const char *thread_name)
|
||||
set_thread_name(pthread_self(), thread_name);
|
||||
}
|
||||
|
||||
void std::string get_current_thread_name() const
|
||||
{
|
||||
char buf[16];
|
||||
return std::string(pthread_getname_np(pthread_self(), buf, 16) == 0 ? buf : "");
|
||||
}
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
// Spawn (n - 1) worker threads on Intel TBB thread pool and name them by an index and a system thread ID.
|
||||
@@ -149,7 +162,7 @@ void name_tbb_thread_pool_threads()
|
||||
} else {
|
||||
assert(range.begin() > 0);
|
||||
std::ostringstream name;
|
||||
name << "slic3r_tbbpool_" << range.begin() << "_" << thread_id;
|
||||
name << "slic3r_tbb_" << range.begin();
|
||||
set_current_thread_name(name.str());
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user