mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-10 08:51:28 +12:00
Small refactoring
This commit is contained in:
parent
8f1a8450be
commit
597d07bf24
46 changed files with 348 additions and 372 deletions
|
@ -2,9 +2,6 @@
|
|||
|
||||
bool SM_IsAborted();
|
||||
void SM_Sleep();
|
||||
size_t SM_GetCurrentThreadId();
|
||||
u32 SM_GetCurrentCPUThreadId();
|
||||
be_t<u32> SM_GetCurrentCPUThreadIdBE();
|
||||
|
||||
enum SMutexResult
|
||||
{
|
||||
|
@ -134,44 +131,5 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template<typename T, typename Tid, Tid (get_tid)()>
|
||||
class SMutexLockerBase
|
||||
{
|
||||
T& sm;
|
||||
public:
|
||||
const Tid tid;
|
||||
|
||||
__forceinline SMutexLockerBase(T& _sm)
|
||||
: sm(_sm)
|
||||
, tid(get_tid())
|
||||
{
|
||||
if (!tid)
|
||||
{
|
||||
if (!SM_IsAborted())
|
||||
{
|
||||
assert(!"SMutexLockerBase: thread id == 0");
|
||||
}
|
||||
return;
|
||||
}
|
||||
sm.lock(tid);
|
||||
}
|
||||
|
||||
__forceinline ~SMutexLockerBase()
|
||||
{
|
||||
if (tid) sm.unlock(tid);
|
||||
}
|
||||
};
|
||||
|
||||
typedef SMutexBase<size_t>
|
||||
SMutexGeneral;
|
||||
typedef SMutexBase<u32>
|
||||
SMutex;
|
||||
typedef SMutexBase<be_t<u32>>
|
||||
SMutexBE;
|
||||
|
||||
typedef SMutexLockerBase<SMutexGeneral, size_t, SM_GetCurrentThreadId>
|
||||
SMutexGeneralLocker;
|
||||
typedef SMutexLockerBase<SMutex, u32, SM_GetCurrentCPUThreadId>
|
||||
SMutexLocker;
|
||||
typedef SMutexLockerBase<SMutexBE, be_t<u32>, SM_GetCurrentCPUThreadIdBE>
|
||||
SMutexBELocker;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue