mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-21 11:02:45 +02:00
pm: Support for 6.0.0
This commit is contained in:
parent
5cecc78d51
commit
ccab6aa737
@ -66,15 +66,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) {
|
||||||
@ -92,45 +92,25 @@ class HosCondVar {
|
|||||||
|
|
||||||
class HosSemaphore {
|
class HosSemaphore {
|
||||||
private:
|
private:
|
||||||
CondVar cv;
|
Semaphore s;
|
||||||
Mutex m;
|
|
||||||
u64 count;
|
|
||||||
public:
|
public:
|
||||||
HosSemaphore() {
|
HosSemaphore() {
|
||||||
count = 0;
|
semaphoreInit(&s, 0);
|
||||||
mutexInit(&m);
|
|
||||||
condvarInit(&cv, &m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HosSemaphore(u64 c) : count(c) {
|
HosSemaphore(u64 c) {
|
||||||
mutexInit(&m);
|
semaphoreInit(&s, c);
|
||||||
condvarInit(&cv, &m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Signal() {
|
void Signal() {
|
||||||
mutexLock(&this->m);
|
semaphoreSignal(&s);
|
||||||
count++;
|
|
||||||
condvarWakeOne(&cv);
|
|
||||||
mutexUnlock(&this->m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wait() {
|
void Wait() {
|
||||||
mutexLock(&this->m);
|
semaphoreWait(&s);
|
||||||
while (!count) {
|
|
||||||
condvarWait(&cv);
|
|
||||||
}
|
|
||||||
count--;
|
|
||||||
mutexUnlock(&this->m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TryWait() {
|
bool TryWait() {
|
||||||
mutexLock(&this->m);
|
return semaphoreTryWait(&s);
|
||||||
bool success = false;
|
|
||||||
if (count) {
|
|
||||||
count--;
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
mutexUnlock(&this->m);
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user