mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-13 02:08:49 +12:00
parent
8011cc8ec4
commit
01dbb8eb9a
42 changed files with 1687 additions and 613 deletions
|
@ -1,15 +1,21 @@
|
|||
#include <stdafx.h>
|
||||
#include <Utilities/SMutex.h>
|
||||
|
||||
|
||||
__forceinline void SM_Sleep()
|
||||
{
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(thread)
|
||||
#else
|
||||
thread_local
|
||||
#endif
|
||||
size_t g_this_thread_id = 0;
|
||||
|
||||
__forceinline size_t SM_GetCurrentThreadId()
|
||||
{
|
||||
return std::hash<std::thread::id>()(std::this_thread::get_id());
|
||||
return g_this_thread_id ? g_this_thread_id : g_this_thread_id = std::hash<std::thread::id>()(std::this_thread::get_id());
|
||||
}
|
||||
|
||||
__forceinline u32 SM_GetCurrentCPUThreadId()
|
||||
|
|
|
@ -21,7 +21,7 @@ template
|
|||
<
|
||||
typename T,
|
||||
u64 free_value = 0,
|
||||
u64 dead_value = ~0,
|
||||
u64 dead_value = 0xffffffff,
|
||||
void (*wait)() = SM_Sleep
|
||||
>
|
||||
class SMutexBase
|
||||
|
@ -139,7 +139,7 @@ class SMutexLockerBase
|
|||
public:
|
||||
const T tid;
|
||||
|
||||
SMutexLockerBase(SMutexBase<T>& _sm)
|
||||
__forceinline SMutexLockerBase(SMutexBase<T>& _sm)
|
||||
: sm(_sm)
|
||||
, tid(get_tid())
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
sm.lock(tid);
|
||||
}
|
||||
|
||||
~SMutexLockerBase()
|
||||
__forceinline ~SMutexLockerBase()
|
||||
{
|
||||
if (tid) sm.unlock(tid);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
template<typename T, u32 SQSize = 666>
|
||||
class SQueue
|
||||
{
|
||||
SMutex m_mutex;
|
||||
SMutexGeneral m_mutex;
|
||||
u32 m_pos;
|
||||
u32 m_count;
|
||||
T m_data[SQSize];
|
||||
|
@ -15,6 +15,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
const u32 GetSize() const
|
||||
{
|
||||
return SQSize;
|
||||
}
|
||||
|
||||
bool Push(const T& data)
|
||||
{
|
||||
while (true)
|
||||
|
@ -35,7 +40,7 @@ public:
|
|||
}
|
||||
|
||||
{
|
||||
SMutexLocker lock(m_mutex);
|
||||
SMutexGeneralLocker lock(m_mutex);
|
||||
|
||||
if (m_count >= SQSize) continue;
|
||||
|
||||
|
@ -66,7 +71,7 @@ public:
|
|||
}
|
||||
|
||||
{
|
||||
SMutexLocker lock(m_mutex);
|
||||
SMutexGeneralLocker lock(m_mutex);
|
||||
|
||||
if (!m_count) continue;
|
||||
|
||||
|
@ -91,7 +96,7 @@ public:
|
|||
|
||||
void Clear()
|
||||
{
|
||||
SMutexLocker lock(m_mutex);
|
||||
SMutexGeneralLocker lock(m_mutex);
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
|
@ -115,7 +120,7 @@ public:
|
|||
}
|
||||
|
||||
{
|
||||
SMutexLocker lock(m_mutex);
|
||||
SMutexGeneralLocker lock(m_mutex);
|
||||
if (m_count) break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue