mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-07-05 17:12:14 +02:00
Merge ffb2dd4f11
into 28e4d4411d
This commit is contained in:
commit
19a9069120
@ -45,15 +45,12 @@ class HosRecursiveMutex {
|
|||||||
HosRecursiveMutex() {
|
HosRecursiveMutex() {
|
||||||
rmutexInit(&this->m);
|
rmutexInit(&this->m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lock() {
|
void lock() {
|
||||||
rmutexLock(&this->m);
|
rmutexLock(&this->m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unlock() {
|
void unlock() {
|
||||||
rmutexUnlock(&this->m);
|
rmutexUnlock(&this->m);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool try_lock() {
|
bool try_lock() {
|
||||||
return rmutexTryLock(&this->m);
|
return rmutexTryLock(&this->m);
|
||||||
}
|
}
|
||||||
@ -66,15 +63,15 @@ class HosCondVar {
|
|||||||
public:
|
public:
|
||||||
HosCondVar() {
|
HosCondVar() {
|
||||||
mutexInit(&m);
|
mutexInit(&m);
|
||||||
condvarInit(&cv, &m);
|
condvarInit(&cv);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result WaitTimeout(u64 timeout) {
|
Result WaitTimeout(u64 timeout) {
|
||||||
return condvarWaitTimeout(&cv, timeout);
|
return condvarWaitTimeout(&cv, &m, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result Wait() {
|
Result Wait() {
|
||||||
return condvarWait(&cv);
|
return condvarWait(&cv, &m);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result Wake(int num) {
|
Result Wake(int num) {
|
||||||
@ -99,12 +96,12 @@ class HosSemaphore {
|
|||||||
HosSemaphore() {
|
HosSemaphore() {
|
||||||
count = 0;
|
count = 0;
|
||||||
mutexInit(&m);
|
mutexInit(&m);
|
||||||
condvarInit(&cv, &m);
|
condvarInit(&cv);
|
||||||
}
|
}
|
||||||
|
|
||||||
HosSemaphore(u64 c) : count(c) {
|
HosSemaphore(u64 c) : count(c) {
|
||||||
mutexInit(&m);
|
mutexInit(&m);
|
||||||
condvarInit(&cv, &m);
|
condvarInit(&cv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Signal() {
|
void Signal() {
|
||||||
@ -117,7 +114,7 @@ class HosSemaphore {
|
|||||||
void Wait() {
|
void Wait() {
|
||||||
mutexLock(&this->m);
|
mutexLock(&this->m);
|
||||||
while (!count) {
|
while (!count) {
|
||||||
condvarWait(&cv);
|
condvarWait(&cv, &m);
|
||||||
}
|
}
|
||||||
count--;
|
count--;
|
||||||
mutexUnlock(&this->m);
|
mutexUnlock(&this->m);
|
||||||
|
Loading…
Reference in New Issue
Block a user