mirror of
https://github.com/quizhizhe/LiteLoaderBDS-1.16.40.git
synced 2025-06-06 20:03:51 +00:00
35 lines
631 B
C++
35 lines
631 B
C++
#include <Utils/CsLock.h>
|
|
|
|
CsLock::CsLock() {
|
|
if (!inited) {
|
|
inited = true;
|
|
InitializeCriticalSection(&cslock);
|
|
}
|
|
}
|
|
|
|
CsLock::~CsLock() {
|
|
if (inited)
|
|
DeleteCriticalSection(&cslock);
|
|
}
|
|
|
|
bool CsLock::tryLock() {
|
|
if (!inited) {
|
|
inited = true;
|
|
InitializeCriticalSection(&cslock);
|
|
}
|
|
return TryEnterCriticalSection(&cslock);
|
|
}
|
|
|
|
bool CsLock::lock() {
|
|
if (!inited) {
|
|
inited = true;
|
|
InitializeCriticalSection(&cslock);
|
|
}
|
|
EnterCriticalSection(&cslock);
|
|
return true;
|
|
}
|
|
|
|
bool CsLock::unlock() {
|
|
LeaveCriticalSection(&cslock);
|
|
return true;
|
|
} |