Core: Use thread_local directly
Both Android and OSX now support it, allowing us to remove the fallback code.
This commit is contained in:
parent
d230194464
commit
e6405f7b2b
|
@ -75,13 +75,6 @@
|
||||||
#include "VideoCommon/RenderBase.h"
|
#include "VideoCommon/RenderBase.h"
|
||||||
#include "VideoCommon/VideoBackendBase.h"
|
#include "VideoCommon/VideoBackendBase.h"
|
||||||
|
|
||||||
// Android and OSX haven't implemented the keyword yet.
|
|
||||||
#if defined __ANDROID__ || defined __APPLE__
|
|
||||||
#include <pthread.h>
|
|
||||||
#else // Everything besides OSX and Android
|
|
||||||
#define ThreadLocalStorage thread_local
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
static bool s_wants_determinism;
|
static bool s_wants_determinism;
|
||||||
|
@ -112,16 +105,7 @@ struct HostJob
|
||||||
static std::mutex s_host_jobs_lock;
|
static std::mutex s_host_jobs_lock;
|
||||||
static std::queue<HostJob> s_host_jobs_queue;
|
static std::queue<HostJob> s_host_jobs_queue;
|
||||||
|
|
||||||
#ifdef ThreadLocalStorage
|
static thread_local bool tls_is_cpu_thread = false;
|
||||||
static ThreadLocalStorage bool tls_is_cpu_thread = false;
|
|
||||||
#else
|
|
||||||
static pthread_key_t s_tls_is_cpu_key;
|
|
||||||
static pthread_once_t s_cpu_key_is_init = PTHREAD_ONCE_INIT;
|
|
||||||
static void InitIsCPUKey()
|
|
||||||
{
|
|
||||||
pthread_key_create(&s_tls_is_cpu_key, nullptr);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void EmuThread(std::unique_ptr<BootParameters> boot);
|
static void EmuThread(std::unique_ptr<BootParameters> boot);
|
||||||
|
|
||||||
|
@ -183,14 +167,7 @@ bool IsRunningInCurrentThread()
|
||||||
|
|
||||||
bool IsCPUThread()
|
bool IsCPUThread()
|
||||||
{
|
{
|
||||||
#ifdef ThreadLocalStorage
|
|
||||||
return tls_is_cpu_thread;
|
return tls_is_cpu_thread;
|
||||||
#else
|
|
||||||
// Use pthread implementation for Android and Mac
|
|
||||||
// Make sure that s_tls_is_cpu_key is initialized
|
|
||||||
pthread_once(&s_cpu_key_is_init, InitIsCPUKey);
|
|
||||||
return pthread_getspecific(s_tls_is_cpu_key);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsGPUThread()
|
bool IsGPUThread()
|
||||||
|
@ -297,26 +274,12 @@ void Stop() // - Hammertime!
|
||||||
|
|
||||||
void DeclareAsCPUThread()
|
void DeclareAsCPUThread()
|
||||||
{
|
{
|
||||||
#ifdef ThreadLocalStorage
|
|
||||||
tls_is_cpu_thread = true;
|
tls_is_cpu_thread = true;
|
||||||
#else
|
|
||||||
// Use pthread implementation for Android and Mac
|
|
||||||
// Make sure that s_tls_is_cpu_key is initialized
|
|
||||||
pthread_once(&s_cpu_key_is_init, InitIsCPUKey);
|
|
||||||
pthread_setspecific(s_tls_is_cpu_key, (void*)true);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UndeclareAsCPUThread()
|
void UndeclareAsCPUThread()
|
||||||
{
|
{
|
||||||
#ifdef ThreadLocalStorage
|
|
||||||
tls_is_cpu_thread = false;
|
tls_is_cpu_thread = false;
|
||||||
#else
|
|
||||||
// Use pthread implementation for Android and Mac
|
|
||||||
// Make sure that s_tls_is_cpu_key is initialized
|
|
||||||
pthread_once(&s_cpu_key_is_init, InitIsCPUKey);
|
|
||||||
pthread_setspecific(s_tls_is_cpu_key, (void*)false);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the CPU Thread only.
|
// For the CPU Thread only.
|
||||||
|
|
Loading…
Reference in New Issue