mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 18:58:00 -06:00
Thread names shortened to 15 characters to fit Posix norm.
Added get_current_thread_name()
This commit is contained in:
parent
be73962699
commit
81b6883710
3 changed files with 19 additions and 2 deletions
|
@ -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());
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue