mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 18:58:00 -06:00
Workaround for OSX non-compliant implementation of
pthread_getname_np / pthread_setname_np
This commit is contained in:
parent
0d2c31d0e4
commit
723406dfea
2 changed files with 36 additions and 0 deletions
|
@ -92,6 +92,36 @@ std::string get_current_thread_name()
|
|||
|
||||
#else // _WIN32
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
// Appe screwed the Posix norm.
|
||||
void set_thread_name(std::thread &thread, const char *thread_name)
|
||||
{
|
||||
// not supported
|
||||
// pthread_setname_np(thread.native_handle(), thread_name);
|
||||
throw CriticalException("Not supported");
|
||||
}
|
||||
|
||||
void set_thread_name(boost::thread &thread, const char *thread_name)
|
||||
{
|
||||
// not supported
|
||||
// pthread_setname_np(thread.native_handle(), thread_name);
|
||||
throw CriticalException("Not supported");
|
||||
}
|
||||
|
||||
void set_current_thread_name(const char *thread_name)
|
||||
{
|
||||
pthread_setname_np(thread_name);
|
||||
}
|
||||
|
||||
std::string get_current_thread_name()
|
||||
{
|
||||
char buf[16];
|
||||
return std::string(thread_getname_np(buf, 16) == 0 ? buf : "");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// posix
|
||||
void set_thread_name(std::thread &thread, const char *thread_name)
|
||||
{
|
||||
|
@ -114,6 +144,8 @@ std::string get_current_thread_name()
|
|||
return std::string(pthread_getname_np(pthread_self(), buf, 16) == 0 ? buf : "");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
// Spawn (n - 1) worker threads on Intel TBB thread pool and name them by an index and a system thread ID.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue