Core/ThreadImpl: Fix warning and merge implementations
This commit is contained in:
parent
6778d6ea33
commit
da6d3afa33
|
|
@ -24,7 +24,7 @@ namespace Nz::PlatformImpl
|
||||||
std::string GetThreadName(pthread_t threadHandle)
|
std::string GetThreadName(pthread_t threadHandle)
|
||||||
{
|
{
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
std::array<char, 16> name;
|
std::array<char, 16> name = { "<error>" };
|
||||||
::pthread_getname_np(threadHandle, &name[0], name.size());
|
::pthread_getname_np(threadHandle, &name[0], name.size());
|
||||||
|
|
||||||
return std::string(&name[0]);
|
return std::string(&name[0]);
|
||||||
|
|
@ -35,12 +35,10 @@ namespace Nz::PlatformImpl
|
||||||
|
|
||||||
void SetCurrentThreadName(const char* threadName)
|
void SetCurrentThreadName(const char* threadName)
|
||||||
{
|
{
|
||||||
#if defined(__linux__)
|
#if defined(__linux__) || defined(__FreeBSD__)
|
||||||
::pthread_setname_np(::pthread_self(), threadName);
|
::pthread_setname_np(::pthread_self(), threadName);
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
::pthread_setname_np(threadName);
|
::pthread_setname_np(threadName);
|
||||||
#elif defined(__FreeBSD__)
|
|
||||||
::pthread_set_name_np(::pthread_self(), threadName);
|
|
||||||
#else
|
#else
|
||||||
NazaraWarning("setting current thread name is not supported on this platform");
|
NazaraWarning("setting current thread name is not supported on this platform");
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -48,15 +46,12 @@ namespace Nz::PlatformImpl
|
||||||
|
|
||||||
void SetThreadName(pthread_t threadHandle, const char* threadName)
|
void SetThreadName(pthread_t threadHandle, const char* threadName)
|
||||||
{
|
{
|
||||||
#if defined(__linux__)
|
#if defined(__linux__) || defined(__FreeBSD__)
|
||||||
::pthread_setname_np(threadHandle, threadName);
|
::pthread_setname_np(threadHandle, threadName);
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
NazaraWarning("only current thread name can be set on MacOS X");
|
NazaraWarning("only current thread name can be set on MacOS X");
|
||||||
#elif defined(__FreeBSD__)
|
|
||||||
::pthread_set_name_np(threadHandle, threadName);
|
|
||||||
#else
|
#else
|
||||||
NazaraWarning("setting a thread name is not supported on this platform");
|
NazaraWarning("setting a thread name is not supported on this platform");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue