1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-05 19:51:45 +00:00

libstratosphere: Fix condvar wrapper primitives

This commit is contained in:
Michael Scire 2018-09-09 07:04:16 -07:00
parent fa0e906129
commit 0cad1935dd

View file

@ -20,61 +20,75 @@
class HosMutex { class HosMutex {
private: private:
Mutex m; Mutex m;
Mutex *GetMutex() {
return &this->m;
}
public: public:
HosMutex() { HosMutex() {
mutexInit(&this->m); mutexInit(GetMutex());
} }
void lock() { void lock() {
mutexLock(&this->m); mutexLock(GetMutex());
} }
void unlock() { void unlock() {
mutexUnlock(&this->m); mutexUnlock(GetMutex());
} }
bool try_lock() { bool try_lock() {
return mutexTryLock(&this->m); return mutexTryLock(GetMutex());
} }
friend class HosCondVar;
}; };
class HosRecursiveMutex { class HosRecursiveMutex {
private: private:
RMutex m; RMutex m;
RMutex *GetMutex() {
return &this->m;
}
public: public:
HosRecursiveMutex() { HosRecursiveMutex() {
rmutexInit(&this->m); rmutexInit(GetMutex());
} }
void lock() { void lock() {
rmutexLock(&this->m); rmutexLock(GetMutex());
} }
void unlock() { void unlock() {
rmutexUnlock(&this->m); rmutexUnlock(GetMutex());
} }
bool try_lock() { bool try_lock() {
return rmutexTryLock(&this->m); return rmutexTryLock(GetMutex());
} }
}; };
class HosCondVar { class HosCondVar {
private: private:
CondVar cv; CondVar cv;
Mutex m;
public: public:
HosCondVar() { HosCondVar() {
mutexInit(&m);
condvarInit(&cv); condvarInit(&cv);
} }
Result WaitTimeout(u64 timeout) { Result WaitTimeout(u64 timeout, HosMutex *hm) {
return condvarWaitTimeout(&cv, &m, timeout); return WaitTimeout(timeout, hm->GetMutex());
} }
Result Wait() { Result Wait(HosMutex *hm) {
return condvarWait(&cv, &m); return Wait(hm->GetMutex());
}
Result WaitTimeout(u64 timeout, Mutex *m) {
return condvarWaitTimeout(&cv, m, timeout);
}
Result Wait(Mutex *m) {
return condvarWait(&cv, m);
} }
Result Wake(int num) { Result Wake(int num) {