2014-02-05 11:55:32 +00:00
|
|
|
#include <stdafx.h>
|
|
|
|
#include <Utilities/SMutex.h>
|
|
|
|
|
|
|
|
__forceinline void SM_Sleep()
|
|
|
|
{
|
|
|
|
Sleep(1);
|
|
|
|
}
|
|
|
|
|
2014-03-31 10:04:34 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
__declspec(thread)
|
2014-04-28 22:54:33 +00:00
|
|
|
#elif __APPLE__
|
|
|
|
__thread
|
2014-03-31 10:04:34 +00:00
|
|
|
#else
|
|
|
|
thread_local
|
|
|
|
#endif
|
|
|
|
size_t g_this_thread_id = 0;
|
|
|
|
|
2014-02-26 11:27:06 +00:00
|
|
|
__forceinline size_t SM_GetCurrentThreadId()
|
2014-02-05 11:55:32 +00:00
|
|
|
{
|
2014-03-31 10:04:34 +00:00
|
|
|
return g_this_thread_id ? g_this_thread_id : g_this_thread_id = std::hash<std::thread::id>()(std::this_thread::get_id());
|
2014-02-05 11:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline u32 SM_GetCurrentCPUThreadId()
|
|
|
|
{
|
|
|
|
if (CPUThread* t = GetCurrentCPUThread())
|
|
|
|
{
|
|
|
|
return t->GetId();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline be_t<u32> SM_GetCurrentCPUThreadIdBE()
|
|
|
|
{
|
|
|
|
return SM_GetCurrentCPUThreadId();
|
2014-02-23 16:52:52 +00:00
|
|
|
}
|