2014-02-05 15:55:32 +04:00
|
|
|
#include <stdafx.h>
|
2014-06-17 17:44:03 +02:00
|
|
|
#include "Utilities/Log.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "Emu/Memory/Memory.h"
|
|
|
|
#include "Emu/System.h"
|
|
|
|
#include "Emu/CPU/CPUThread.h"
|
|
|
|
|
|
|
|
#include "Utilities/SMutex.h"
|
2014-02-05 15:55:32 +04:00
|
|
|
|
|
|
|
__forceinline void SM_Sleep()
|
|
|
|
{
|
2014-06-20 15:00:36 +04:00
|
|
|
if (NamedThreadBase* t = GetCurrentNamedThread())
|
|
|
|
{
|
|
|
|
t->WaitForAnySignal();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Sleep(1);
|
|
|
|
}
|
2014-02-05 15:55:32 +04:00
|
|
|
}
|
|
|
|
|
2014-06-19 17:50:18 +04:00
|
|
|
thread_local size_t g_this_thread_id = 0;
|
2014-03-31 12:04:34 +02:00
|
|
|
|
2014-02-26 15:27:06 +04:00
|
|
|
__forceinline size_t SM_GetCurrentThreadId()
|
2014-02-05 15:55:32 +04:00
|
|
|
{
|
2014-03-31 12:04:34 +02: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 15:55:32 +04: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 17:52:52 +01:00
|
|
|
}
|