diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-02-13 17:01:44 -0400 |
---|---|---|
committer | FernandoS27 <fsahmkow27@gmail.com> | 2020-02-13 19:10:33 -0400 |
commit | 2bc949628dfa2efe9a18660b9d662e2a25cef9f9 (patch) | |
tree | 84b72d7b0fcf8838c34c9ae0943dc297fa539e5b /src/core/hle/kernel/synchronization.cpp | |
parent | 1e6f8aba04b7be0f90b97aed2527558c755935d6 (diff) |
Core: Address Feedback
Diffstat (limited to 'src/core/hle/kernel/synchronization.cpp')
-rw-r--r-- | src/core/hle/kernel/synchronization.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/core/hle/kernel/synchronization.cpp b/src/core/hle/kernel/synchronization.cpp index 25afc162fc..dc37fad1a7 100644 --- a/src/core/hle/kernel/synchronization.cpp +++ b/src/core/hle/kernel/synchronization.cpp @@ -4,6 +4,7 @@ #include "core/core.h" #include "core/hle/kernel/errors.h" +#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/scheduler.h" #include "core/hle/kernel/synchronization.h" @@ -27,30 +28,30 @@ static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, std::shared_p thread->SetWaitSynchronizationResult(RESULT_SUCCESS); thread->SetWaitSynchronizationOutput(static_cast<u32>(index)); return true; -}; +} Synchronization::Synchronization(Core::System& system) : system{system} {} void Synchronization::SignalObject(SynchronizationObject& obj) const { if (obj.IsSignaled()) { obj.WakeupAllWaitingThreads(); - }; + } } std::pair<ResultCode, Handle> Synchronization::WaitFor( std::vector<std::shared_ptr<SynchronizationObject>>& sync_objects, s64 nano_seconds) { auto* const thread = system.CurrentScheduler().GetCurrentThread(); // Find the first object that is acquirable in the provided list of objects - auto itr = std::find_if(sync_objects.begin(), sync_objects.end(), - [thread](const std::shared_ptr<SynchronizationObject>& object) { - return object->IsSignaled(); - }); + const auto itr = std::find_if(sync_objects.begin(), sync_objects.end(), + [thread](const std::shared_ptr<SynchronizationObject>& object) { + return object->IsSignaled(); + }); if (itr != sync_objects.end()) { // We found a ready object, acquire it and set the result value SynchronizationObject* object = itr->get(); object->Acquire(thread); - u32 index = static_cast<s32>(std::distance(sync_objects.begin(), itr)); + const u32 index = static_cast<s32>(std::distance(sync_objects.begin(), itr)); return {RESULT_SUCCESS, index}; } @@ -59,12 +60,12 @@ std::pair<ResultCode, Handle> Synchronization::WaitFor( // If a timeout value of 0 was provided, just return the Timeout error code instead of // suspending the thread. if (nano_seconds == 0) { - return {RESULT_TIMEOUT, 0}; + return {RESULT_TIMEOUT, InvalidHandle}; } if (thread->IsSyncCancelled()) { thread->SetSyncCancelled(false); - return {ERR_SYNCHRONIZATION_CANCELED, 0}; + return {ERR_SYNCHRONIZATION_CANCELED, InvalidHandle}; } for (auto& object : sync_objects) { @@ -80,7 +81,7 @@ std::pair<ResultCode, Handle> Synchronization::WaitFor( system.PrepareReschedule(thread->GetProcessorID()); - return {RESULT_TIMEOUT, 0}; + return {RESULT_TIMEOUT, InvalidHandle}; } } // namespace Kernel |