WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" pure virtual.

This commit is contained in:
bunnei 2015-01-20 17:41:12 -05:00
parent 69c5830ef2
commit c68eb15695
9 changed files with 22 additions and 23 deletions

View file

@ -28,7 +28,7 @@ public:
bool signaled; ///< Whether the event has already been signaled bool signaled; ///< Whether the event has already been signaled
std::string name; ///< Name of event (optional) std::string name; ///< Name of event (optional)
ResultVal<bool> Wait() override { ResultVal<bool> ShouldWait() override {
return MakeResult<bool>(!signaled); return MakeResult<bool>(!signaled);
} }

View file

@ -117,22 +117,16 @@ class WaitObject : public Object {
public: 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 * @return True if the current thread should wait due to this object being unavailable
*/ */
virtual ResultVal<bool> Wait() { virtual ResultVal<bool> ShouldWait() = 0;
LOG_ERROR(Kernel, "(UNIMPLEMENTED)");
return UnimplementedFunction(ErrorModule::Kernel);
}
/** /**
* 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 * @return True if we were able to acquire this object, otherwise false
*/ */
virtual ResultVal<bool> Acquire() { virtual ResultVal<bool> Acquire() = 0;
LOG_ERROR(Kernel, "(UNIMPLEMENTED)");
return UnimplementedFunction(ErrorModule::Kernel);
}
/** /**
* Add a thread to wait on this object * Add a thread to wait on this object

View file

@ -27,7 +27,7 @@ public:
std::string name; ///< Name of mutex (optional) std::string name; ///< Name of mutex (optional)
SharedPtr<Thread> current_thread; ///< Thread that has acquired the mutex SharedPtr<Thread> current_thread; ///< Thread that has acquired the mutex
ResultVal<bool> Wait() override; ResultVal<bool> ShouldWait() override;
ResultVal<bool> Acquire() override; ResultVal<bool> Acquire() override;
}; };
@ -159,7 +159,7 @@ Handle CreateMutex(bool initial_locked, const std::string& name) {
return handle; return handle;
} }
ResultVal<bool> Mutex::Wait() { ResultVal<bool> Mutex::ShouldWait() {
return MakeResult<bool>(locked && (current_thread != GetCurrentThread())); return MakeResult<bool>(locked && (current_thread != GetCurrentThread()));
} }

View file

@ -32,7 +32,7 @@ public:
return available_count > 0; return available_count > 0;
} }
ResultVal<bool> Wait() override { ResultVal<bool> ShouldWait() override {
return MakeResult<bool>(!IsAvailable()); return MakeResult<bool>(!IsAvailable());
} }

View file

@ -54,11 +54,16 @@ public:
*/ */
virtual ResultVal<bool> SyncRequest() = 0; virtual ResultVal<bool> SyncRequest() = 0;
ResultVal<bool> Wait() override { // TODO(bunnei): These functions exist to satisfy a hardware test with a Session object
// TODO(bunnei): This function exists to satisfy a hardware test with a Session object // passed into WaitSynchronization. Figure out the meaning of them.
// passed into WaitSynchronization. Not sure if it's possible for this to ever be false?
ResultVal<bool> ShouldWait() override {
return MakeResult<bool>(true); return MakeResult<bool>(true);
} }
ResultVal<bool> Acquire() override {
return MakeResult<bool>(false);
}
}; };
} }

View file

@ -22,7 +22,7 @@
namespace Kernel { namespace Kernel {
ResultVal<bool> Thread::Wait() { ResultVal<bool> Thread::ShouldWait() {
return MakeResult<bool>(status != THREADSTATUS_DORMANT); return MakeResult<bool>(status != THREADSTATUS_DORMANT);
} }
@ -269,7 +269,7 @@ void Thread::ReleaseWaitObject(WaitObject* wait_object) {
// Iterate through all waiting objects to check availability... // Iterate through all waiting objects to check availability...
for (auto itr = wait_objects.begin(); itr != wait_objects.end(); ++itr) { for (auto itr = wait_objects.begin(); itr != wait_objects.end(); ++itr) {
auto res = (*itr)->Wait(); auto res = (*itr)->ShouldWait();
if (*res && res.Succeeded()) if (*res && res.Succeeded())
wait_all_failed = true; wait_all_failed = true;

View file

@ -58,7 +58,7 @@ public:
inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; }
inline bool IsIdle() const { return idle; } inline bool IsIdle() const { return idle; }
ResultVal<bool> Wait() override; ResultVal<bool> ShouldWait() override;
ResultVal<bool> Acquire() override; ResultVal<bool> Acquire() override;
s32 GetPriority() const { return current_priority; } s32 GetPriority() const { return current_priority; }

View file

@ -29,7 +29,7 @@ public:
u64 initial_delay; ///< The delay until the timer fires for the first time 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 u64 interval_delay; ///< The delay until the timer fires after the first time
ResultVal<bool> Wait() override { ResultVal<bool> ShouldWait() override {
return MakeResult<bool>(!signaled); return MakeResult<bool>(!signaled);
} }

View file

@ -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, LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle,
object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds); object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds);
ResultVal<bool> wait = object->Wait(); ResultVal<bool> wait = object->ShouldWait();
// Check for next thread to schedule // Check for next thread to schedule
if (wait.Succeeded() && *wait) { if (wait.Succeeded() && *wait) {
@ -167,7 +167,7 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
if (object == nullptr) if (object == nullptr)
return InvalidHandle(ErrorModule::Kernel).raw; return InvalidHandle(ErrorModule::Kernel).raw;
ResultVal<bool> wait = object->Wait(); ResultVal<bool> wait = object->ShouldWait();
// Check if the current thread should wait on this object... // Check if the current thread should wait on this object...
if (wait.Succeeded() && *wait) { if (wait.Succeeded() && *wait) {