2014-08-28 16:29:05 +00:00
|
|
|
#include "stdafx.h"
|
2014-06-02 17:27:24 +00:00
|
|
|
#include "Emu/System.h"
|
|
|
|
#include "Emu/CPU/CPUThread.h"
|
|
|
|
|
|
|
|
#include "Utilities/SMutex.h"
|
2014-02-05 11:55:32 +00:00
|
|
|
|
2014-08-22 16:36:27 +00:00
|
|
|
bool SM_IsAborted()
|
|
|
|
{
|
|
|
|
return Emu.IsStopped();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SM_Sleep()
|
2014-02-05 11:55:32 +00:00
|
|
|
{
|
2014-06-20 11:00:36 +00:00
|
|
|
if (NamedThreadBase* t = GetCurrentNamedThread())
|
|
|
|
{
|
|
|
|
t->WaitForAnySignal();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-12 07:02:39 +00:00
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
2014-06-20 11:00:36 +00:00
|
|
|
}
|
2014-02-05 11:55:32 +00:00
|
|
|
}
|
|
|
|
|
2014-06-19 13:50:18 +00:00
|
|
|
thread_local size_t g_this_thread_id = 0;
|
2014-03-31 10:04:34 +00:00
|
|
|
|
2014-08-22 16:36:27 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-08-22 16:36:27 +00:00
|
|
|
u32 SM_GetCurrentCPUThreadId()
|
2014-02-05 11:55:32 +00:00
|
|
|
{
|
|
|
|
if (CPUThread* t = GetCurrentCPUThread())
|
|
|
|
{
|
|
|
|
return t->GetId();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-22 16:36:27 +00:00
|
|
|
be_t<u32> SM_GetCurrentCPUThreadIdBE()
|
2014-02-05 11:55:32 +00:00
|
|
|
{
|
2014-07-18 16:55:26 +00:00
|
|
|
return be_t<u32>::MakeFromLE(SM_GetCurrentCPUThreadId());
|
2014-02-23 16:52:52 +00:00
|
|
|
}
|