From ffb2dd4f115f168459b2df3c3fc75436e50161f3 Mon Sep 17 00:00:00 2001 From: rkx1209 Date: Sun, 19 Aug 2018 18:56:58 +0900 Subject: [PATCH] Change CondVar API to latest version See: https://github.com/switchbrew/libnx/commit/1e349b6ce8cb1813091b7b58a43c7a9697775b4f --- .../include/stratosphere/hossynch.hpp | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/stratosphere/libstratosphere/include/stratosphere/hossynch.hpp b/stratosphere/libstratosphere/include/stratosphere/hossynch.hpp index d75379aab..504dab485 100644 --- a/stratosphere/libstratosphere/include/stratosphere/hossynch.hpp +++ b/stratosphere/libstratosphere/include/stratosphere/hossynch.hpp @@ -8,15 +8,15 @@ class HosMutex { HosMutex() { mutexInit(&this->m); } - + void lock() { mutexLock(&this->m); } - + void unlock() { mutexUnlock(&this->m); } - + bool try_lock() { return mutexTryLock(&this->m); } @@ -29,15 +29,12 @@ class HosRecursiveMutex { HosRecursiveMutex() { rmutexInit(&this->m); } - void lock() { rmutexLock(&this->m); } - void unlock() { rmutexUnlock(&this->m); } - bool try_lock() { return rmutexTryLock(&this->m); } @@ -50,25 +47,25 @@ class HosCondVar { public: HosCondVar() { mutexInit(&m); - condvarInit(&cv, &m); + condvarInit(&cv); } - + Result WaitTimeout(u64 timeout) { - return condvarWaitTimeout(&cv, timeout); + return condvarWaitTimeout(&cv, &m, timeout); } - + Result Wait() { - return condvarWait(&cv); + return condvarWait(&cv, &m); } - + Result Wake(int num) { return condvarWake(&cv, num); } - + Result WakeOne() { return condvarWakeOne(&cv); } - + Result WakeAll() { return condvarWakeAll(&cv); } @@ -83,30 +80,30 @@ class HosSemaphore { HosSemaphore() { count = 0; mutexInit(&m); - condvarInit(&cv, &m); + condvarInit(&cv); } - + HosSemaphore(u64 c) : count(c) { mutexInit(&m); - condvarInit(&cv, &m); + condvarInit(&cv); } - + void Signal() { mutexLock(&this->m); count++; condvarWakeOne(&cv); mutexUnlock(&this->m); } - + void Wait() { mutexLock(&this->m); while (!count) { - condvarWait(&cv); + condvarWait(&cv, &m); } count--; mutexUnlock(&this->m); } - + bool TryWait() { mutexLock(&this->m); bool success = false;