Core: Set thread names when possible.

This doesn't seem to be working for lldb, though.
This commit is contained in:
Unknown W. Brackets 2018-01-21 09:47:07 -08:00 committed by Henrik Rydgård
parent 95bcda409d
commit 062566b67c
2 changed files with 8 additions and 3 deletions

View File

@ -35,6 +35,7 @@ SDLJoystick *joystick = NULL;
#include "util/text/parsers.h" #include "util/text/parsers.h"
#include "math/math_util.h" #include "math/math_util.h"
#include "thin3d/GLRenderManager.h" #include "thin3d/GLRenderManager.h"
#include "thread/threadutil.h"
#include "Common/Vulkan/VulkanContext.h" #include "Common/Vulkan/VulkanContext.h"
#include "Common/Vulkan/VulkanDebug.h" #include "Common/Vulkan/VulkanDebug.h"
#include "math.h" #include "math.h"
@ -725,6 +726,8 @@ static std::thread emuThread;
static std::atomic<int> emuThreadState((int)EmuThreadState::DISABLED); static std::atomic<int> emuThreadState((int)EmuThreadState::DISABLED);
static void EmuThreadFunc() { static void EmuThreadFunc() {
setCurrentThreadName("Emu");
// There's no real requirement that NativeInit happen on this thread. // There's no real requirement that NativeInit happen on this thread.
// We just call the update/render loop here. // We just call the update/render loop here.
emuThreadState = (int)EmuThreadState::RUNNING; emuThreadState = (int)EmuThreadState::RUNNING;

View File

@ -12,7 +12,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "thread/threadutil.h" #include "thread/threadutil.h"
#ifdef __ANDROID__ #if defined(__ANDROID__) || defined(__APPLE__) || (defined(__GLIBC__) && defined(_GNU_SOURCE))
#include <pthread.h> #include <pthread.h>
#endif #endif
@ -96,10 +96,12 @@ void setCurrentThreadName(const char* threadName) {
{} {}
#else #else
#if defined(__ANDROID__) #if defined(__ANDROID__) || (defined(__GLIBC__) && defined(_GNU_SOURCE))
pthread_setname_np(pthread_self(), threadName); pthread_setname_np(pthread_self(), threadName);
#elif defined(__APPLE__)
pthread_setname_np(threadName);
// #else // #else
// pthread_setname_np(thread_name); // pthread_setname_np(threadName);
#endif #endif
// Do nothing // Do nothing