mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-05-16 20:32:43 -07:00
Workaround for OSX non-compliant implementation of
pthread_getname_np / pthread_setname_np
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user