diff options
author | bunnei <bunneidev@gmail.com> | 2015-01-21 00:16:45 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2015-01-22 02:47:49 +0100 |
commit | 15b6a4d9add6b260a2a1a84ab6228addced4f851 (patch) | |
tree | e9934863ebd6483cabae0f6c280fab7e34eee32e /src/core/hle | |
parent | WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" pure virtual. (diff) | |
download | yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.gz yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.bz2 yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.lz yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.xz yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.zst yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.zip |
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/kernel/event.cpp | 10 | ||||
-rw-r--r-- | src/core/hle/kernel/kernel.h | 9 | ||||
-rw-r--r-- | src/core/hle/kernel/mutex.cpp | 24 | ||||
-rw-r--r-- | src/core/hle/kernel/semaphore.cpp | 28 | ||||
-rw-r--r-- | src/core/hle/kernel/session.h | 8 | ||||
-rw-r--r-- | src/core/hle/kernel/thread.cpp | 12 | ||||
-rw-r--r-- | src/core/hle/kernel/thread.h | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/timer.cpp | 8 | ||||
-rw-r--r-- | src/core/hle/svc.cpp | 10 |
9 files changed, 42 insertions, 71 deletions
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index bed856020..cdacba1d9 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp @@ -28,16 +28,16 @@ public: bool signaled; ///< Whether the event has already been signaled std::string name; ///< Name of event (optional) - ResultVal<bool> ShouldWait() override { - return MakeResult<bool>(!signaled); + bool ShouldWait() override { + return !signaled; } - ResultVal<bool> Acquire() override { + void Acquire() override { + _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); + // Release the event if it's not sticky... if (reset_type != RESETTYPE_STICKY) signaled = false; - - return MakeResult<bool>(true); } }; diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 1bb0b55bd..c26726223 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -120,13 +120,10 @@ public: * Check if the current thread should wait until the object is available * @return True if the current thread should wait due to this object being unavailable */ - virtual ResultVal<bool> ShouldWait() = 0; + virtual bool ShouldWait() = 0; - /** - * Acquire/lock the object if it is available - * @return True if we were able to acquire this object, otherwise false - */ - virtual ResultVal<bool> Acquire() = 0; + /// Acquire/lock the object if it is available + virtual void Acquire() = 0; /** * Add a thread to wait on this object diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 01d2263ff..355824e60 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -27,8 +27,8 @@ public: std::string name; ///< Name of mutex (optional) SharedPtr<Thread> current_thread; ///< Thread that has acquired the mutex - ResultVal<bool> ShouldWait() override; - ResultVal<bool> Acquire() override; + bool ShouldWait() override; + void Acquire() override; }; //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -159,20 +159,14 @@ Handle CreateMutex(bool initial_locked, const std::string& name) { return handle; } -ResultVal<bool> Mutex::ShouldWait() { - return MakeResult<bool>(locked && (current_thread != GetCurrentThread())); +bool Mutex::ShouldWait() { + return locked && current_thread != GetCurrentThread(); } -ResultVal<bool> Mutex::Acquire() { - bool res = false; - - if (!locked) { - // Lock the mutex when the first thread accesses it - locked = true; - res = true; - MutexAcquireLock(this); - } - - return MakeResult<bool>(res); +void Mutex::Acquire() { + _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); + locked = true; + MutexAcquireLock(this); } + } // namespace diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp index 24d41c0b3..274680568 100644 --- a/src/core/hle/kernel/semaphore.cpp +++ b/src/core/hle/kernel/semaphore.cpp @@ -24,27 +24,13 @@ public: s32 available_count; ///< Number of free slots left in the semaphore std::string name; ///< Name of semaphore (optional) - /** - * Tests whether a semaphore still has free slots - * @return Whether the semaphore is available - */ - bool IsAvailable() const { - return available_count > 0; + bool ShouldWait() override { + return available_count <= 0; } - ResultVal<bool> ShouldWait() override { - return MakeResult<bool>(!IsAvailable()); - } - - ResultVal<bool> Acquire() override { - bool res = false; - - if (IsAvailable()) { - --available_count; - res = true; - } - - return MakeResult<bool>(res); + void Acquire() override { + _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); + --available_count; } }; @@ -84,8 +70,8 @@ ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) { // Notify some of the threads that the semaphore has been released // stop once the semaphore is full again or there are no more waiting threads - while (semaphore->IsAvailable() && semaphore->ReleaseNextThread() != nullptr) { - --semaphore->available_count; + while (!semaphore->ShouldWait() && semaphore->ReleaseNextThread() != nullptr) { + semaphore->Acquire(); } return RESULT_SUCCESS; diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h index f0343d9b2..1788e4375 100644 --- a/src/core/hle/kernel/session.h +++ b/src/core/hle/kernel/session.h @@ -57,12 +57,12 @@ public: // TODO(bunnei): These functions exist to satisfy a hardware test with a Session object // passed into WaitSynchronization. Figure out the meaning of them. - ResultVal<bool> ShouldWait() override { - return MakeResult<bool>(true); + bool ShouldWait() override { + return true; } - ResultVal<bool> Acquire() override { - return MakeResult<bool>(false); + void Acquire() override { + _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); } }; diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 8a2cf8bf4..7a7f430cf 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -22,12 +22,12 @@ namespace Kernel { -ResultVal<bool> Thread::ShouldWait() { - return MakeResult<bool>(status != THREADSTATUS_DORMANT); +bool Thread::ShouldWait() { + return status != THREADSTATUS_DORMANT; } -ResultVal<bool> Thread::Acquire() { - return MakeResult<bool>(true); +void Thread::Acquire() { + _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); } // Lists all thread ids that aren't deleted/etc. @@ -269,9 +269,7 @@ void Thread::ReleaseWaitObject(WaitObject* wait_object) { // Iterate through all waiting objects to check availability... for (auto itr = wait_objects.begin(); itr != wait_objects.end(); ++itr) { - auto res = (*itr)->ShouldWait(); - - if (*res && res.Succeeded()) + if ((*itr)->ShouldWait()) wait_all_failed = true; // The output should be the last index of wait_object diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index b23638bd1..bed9f714a 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -58,8 +58,8 @@ public: inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } inline bool IsIdle() const { return idle; } - ResultVal<bool> ShouldWait() override; - ResultVal<bool> Acquire() override; + bool ShouldWait() override; + void Acquire() override; s32 GetPriority() const { return current_priority; } void SetPriority(s32 priority); diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 1729cca0f..8d9db92a4 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -29,12 +29,12 @@ public: u64 initial_delay; ///< The delay until the timer fires for the first time u64 interval_delay; ///< The delay until the timer fires after the first time - ResultVal<bool> ShouldWait() override { - return MakeResult<bool>(!signaled); + bool ShouldWait() override { + return !signaled; } - ResultVal<bool> Acquire() override { - return MakeResult<bool>(true); + void Acquire() override { + _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); } }; diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index fd2d22727..f6c912502 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -122,10 +122,8 @@ static Result WaitSynchronization1(Handle handle, s64 nano_seconds) { LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds); - ResultVal<bool> wait = object->ShouldWait(); - // Check for next thread to schedule - if (wait.Succeeded() && *wait) { + if (object->ShouldWait()) { object->AddWaitingThread(Kernel::GetCurrentThread()); Kernel::WaitCurrentThread_WaitSynchronization(object); @@ -138,7 +136,7 @@ static Result WaitSynchronization1(Handle handle, s64 nano_seconds) { object->Acquire(); } - return wait.Code().raw; + return RESULT_SUCCESS.raw; } /// Wait for the given handles to synchronize, timeout after the specified nanoseconds @@ -167,10 +165,8 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, if (object == nullptr) return InvalidHandle(ErrorModule::Kernel).raw; - ResultVal<bool> wait = object->ShouldWait(); - // Check if the current thread should wait on this object... - if (wait.Succeeded() && *wait) { + if (object->ShouldWait()) { // Check we are waiting on all objects... if (wait_all) |