From c68eb1569549ae49ae25c6c29cec2e10d8329f2d Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 20 Jan 2015 17:41:12 -0500 Subject: WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" pure virtual. --- src/core/hle/kernel/event.cpp | 2 +- src/core/hle/kernel/kernel.h | 14 ++++---------- src/core/hle/kernel/mutex.cpp | 4 ++-- src/core/hle/kernel/semaphore.cpp | 2 +- src/core/hle/kernel/session.h | 11 ++++++++--- src/core/hle/kernel/thread.cpp | 4 ++-- src/core/hle/kernel/thread.h | 2 +- src/core/hle/kernel/timer.cpp | 2 +- src/core/hle/svc.cpp | 4 ++-- 9 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index 37f01652e..bed856020 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp @@ -28,7 +28,7 @@ public: bool signaled; ///< Whether the event has already been signaled std::string name; ///< Name of event (optional) - ResultVal Wait() override { + ResultVal ShouldWait() override { return MakeResult(!signaled); } diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index ca9ccf4bf..1bb0b55bd 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -117,22 +117,16 @@ class WaitObject : public Object { public: /** - * Check if this object is available + * 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 Wait() { - LOG_ERROR(Kernel, "(UNIMPLEMENTED)"); - return UnimplementedFunction(ErrorModule::Kernel); - } + virtual ResultVal ShouldWait() = 0; /** - * Acquire/lock the this object if it is available + * Acquire/lock the object if it is available * @return True if we were able to acquire this object, otherwise false */ - virtual ResultVal Acquire() { - LOG_ERROR(Kernel, "(UNIMPLEMENTED)"); - return UnimplementedFunction(ErrorModule::Kernel); - } + virtual ResultVal 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 6cd140376..01d2263ff 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -27,7 +27,7 @@ public: std::string name; ///< Name of mutex (optional) SharedPtr current_thread; ///< Thread that has acquired the mutex - ResultVal Wait() override; + ResultVal ShouldWait() override; ResultVal Acquire() override; }; @@ -159,7 +159,7 @@ Handle CreateMutex(bool initial_locked, const std::string& name) { return handle; } -ResultVal Mutex::Wait() { +ResultVal Mutex::ShouldWait() { return MakeResult(locked && (current_thread != GetCurrentThread())); } diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp index 6ccdb2a8f..24d41c0b3 100644 --- a/src/core/hle/kernel/semaphore.cpp +++ b/src/core/hle/kernel/semaphore.cpp @@ -32,7 +32,7 @@ public: return available_count > 0; } - ResultVal Wait() override { + ResultVal ShouldWait() override { return MakeResult(!IsAvailable()); } diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h index e11f727a5..f0343d9b2 100644 --- a/src/core/hle/kernel/session.h +++ b/src/core/hle/kernel/session.h @@ -54,11 +54,16 @@ public: */ virtual ResultVal SyncRequest() = 0; - ResultVal Wait() override { - // TODO(bunnei): This function exists to satisfy a hardware test with a Session object - // passed into WaitSynchronization. Not sure if it's possible for this to ever be false? + // TODO(bunnei): These functions exist to satisfy a hardware test with a Session object + // passed into WaitSynchronization. Figure out the meaning of them. + + ResultVal ShouldWait() override { return MakeResult(true); } + + ResultVal Acquire() override { + return MakeResult(false); + } }; } diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 271828ea7..8a2cf8bf4 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -22,7 +22,7 @@ namespace Kernel { -ResultVal Thread::Wait() { +ResultVal Thread::ShouldWait() { return MakeResult(status != THREADSTATUS_DORMANT); } @@ -269,7 +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)->Wait(); + auto res = (*itr)->ShouldWait(); if (*res && res.Succeeded()) wait_all_failed = true; diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index a3a17e6c0..b23638bd1 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -58,7 +58,7 @@ public: inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } inline bool IsIdle() const { return idle; } - ResultVal Wait() override; + ResultVal ShouldWait() override; ResultVal Acquire() override; s32 GetPriority() const { return current_priority; } diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 62bdf07c7..1729cca0f 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -29,7 +29,7 @@ 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 Wait() override { + ResultVal ShouldWait() override { return MakeResult(!signaled); } diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index d72839172..fd2d22727 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -122,7 +122,7 @@ 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 wait = object->Wait(); + ResultVal wait = object->ShouldWait(); // Check for next thread to schedule if (wait.Succeeded() && *wait) { @@ -167,7 +167,7 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, if (object == nullptr) return InvalidHandle(ErrorModule::Kernel).raw; - ResultVal wait = object->Wait(); + ResultVal wait = object->ShouldWait(); // Check if the current thread should wait on this object... if (wait.Succeeded() && *wait) { -- cgit v1.2.3