mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-01-26 12:59:18 +01:00
WinRT: made SDL_ThreadID() return the native thread ID, rather than a fake one
This commit is contained in:
parent
3fce6688b8
commit
6300b3606f
@ -33,13 +33,8 @@ extern "C" {
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
|
|
||||||
// HACK: Mimic C++11's thread_local keyword on Visual C++ 2012 (aka. VC++ 11)
|
#ifdef __WINRT__
|
||||||
// TODO: make sure this hack doesn't get used if and when Visual C++ supports
|
#include <Windows.h>
|
||||||
// the official, 'thread_local' keyword.
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define thread_local __declspec(thread)
|
|
||||||
// Documentation for __declspec(thread) can be found online at:
|
|
||||||
// http://msdn.microsoft.com/en-us/library/2s9wt68x.aspx
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -78,6 +73,10 @@ extern "C"
|
|||||||
SDL_threadID
|
SDL_threadID
|
||||||
SDL_ThreadID(void)
|
SDL_ThreadID(void)
|
||||||
{
|
{
|
||||||
|
#ifdef __WINRT__
|
||||||
|
return GetCurrentThreadId();
|
||||||
|
#else
|
||||||
|
// HACK: Mimick a thread ID, if one isn't otherwise available.
|
||||||
static thread_local SDL_threadID current_thread_id = 0;
|
static thread_local SDL_threadID current_thread_id = 0;
|
||||||
static SDL_threadID next_thread_id = 1;
|
static SDL_threadID next_thread_id = 1;
|
||||||
static std::mutex next_thread_id_mutex;
|
static std::mutex next_thread_id_mutex;
|
||||||
@ -89,6 +88,7 @@ SDL_ThreadID(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return current_thread_id;
|
return current_thread_id;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
Loading…
Reference in New Issue
Block a user