diff options
| author | 2020-02-13 17:01:44 -0400 | |
|---|---|---|
| committer | 2020-02-13 19:10:33 -0400 | |
| commit | 2bc949628dfa2efe9a18660b9d662e2a25cef9f9 (patch) | |
| tree | 84b72d7b0fcf8838c34c9ae0943dc297fa539e5b /src/core/hle/kernel/synchronization.cpp | |
| parent | Core: Set all hardware emulation constants in a single file. (diff) | |
| download | yuzu-2bc949628dfa2efe9a18660b9d662e2a25cef9f9.tar.gz yuzu-2bc949628dfa2efe9a18660b9d662e2a25cef9f9.tar.xz yuzu-2bc949628dfa2efe9a18660b9d662e2a25cef9f9.zip | |
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 25afc162f..dc37fad1a 100644 --- a/src/core/hle/kernel/synchronization.cpp +++ b/src/core/hle/kernel/synchronization.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include "core/core.h" | 5 | #include "core/core.h" |
| 6 | #include "core/hle/kernel/errors.h" | 6 | #include "core/hle/kernel/errors.h" |
| 7 | #include "core/hle/kernel/handle_table.h" | ||
| 7 | #include "core/hle/kernel/kernel.h" | 8 | #include "core/hle/kernel/kernel.h" |
| 8 | #include "core/hle/kernel/scheduler.h" | 9 | #include "core/hle/kernel/scheduler.h" |
| 9 | #include "core/hle/kernel/synchronization.h" | 10 | #include "core/hle/kernel/synchronization.h" |
| @@ -27,30 +28,30 @@ static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, std::shared_p | |||
| 27 | thread->SetWaitSynchronizationResult(RESULT_SUCCESS); | 28 | thread->SetWaitSynchronizationResult(RESULT_SUCCESS); |
| 28 | thread->SetWaitSynchronizationOutput(static_cast<u32>(index)); | 29 | thread->SetWaitSynchronizationOutput(static_cast<u32>(index)); |
| 29 | return true; | 30 | return true; |
| 30 | }; | 31 | } |
| 31 | 32 | ||
| 32 | Synchronization::Synchronization(Core::System& system) : system{system} {} | 33 | Synchronization::Synchronization(Core::System& system) : system{system} {} |
| 33 | 34 | ||
| 34 | void Synchronization::SignalObject(SynchronizationObject& obj) const { | 35 | void Synchronization::SignalObject(SynchronizationObject& obj) const { |
| 35 | if (obj.IsSignaled()) { | 36 | if (obj.IsSignaled()) { |
| 36 | obj.WakeupAllWaitingThreads(); | 37 | obj.WakeupAllWaitingThreads(); |
| 37 | }; | 38 | } |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | std::pair<ResultCode, Handle> Synchronization::WaitFor( | 41 | std::pair<ResultCode, Handle> Synchronization::WaitFor( |
| 41 | std::vector<std::shared_ptr<SynchronizationObject>>& sync_objects, s64 nano_seconds) { | 42 | std::vector<std::shared_ptr<SynchronizationObject>>& sync_objects, s64 nano_seconds) { |
| 42 | auto* const thread = system.CurrentScheduler().GetCurrentThread(); | 43 | auto* const thread = system.CurrentScheduler().GetCurrentThread(); |
| 43 | // Find the first object that is acquirable in the provided list of objects | 44 | // Find the first object that is acquirable in the provided list of objects |
| 44 | auto itr = std::find_if(sync_objects.begin(), sync_objects.end(), | 45 | const auto itr = std::find_if(sync_objects.begin(), sync_objects.end(), |
| 45 | [thread](const std::shared_ptr<SynchronizationObject>& object) { | 46 | [thread](const std::shared_ptr<SynchronizationObject>& object) { |
| 46 | return object->IsSignaled(); | 47 | return object->IsSignaled(); |
| 47 | }); | 48 | }); |
| 48 | 49 | ||
| 49 | if (itr != sync_objects.end()) { | 50 | if (itr != sync_objects.end()) { |
| 50 | // We found a ready object, acquire it and set the result value | 51 | // We found a ready object, acquire it and set the result value |
| 51 | SynchronizationObject* object = itr->get(); | 52 | SynchronizationObject* object = itr->get(); |
| 52 | object->Acquire(thread); | 53 | object->Acquire(thread); |
| 53 | u32 index = static_cast<s32>(std::distance(sync_objects.begin(), itr)); | 54 | const u32 index = static_cast<s32>(std::distance(sync_objects.begin(), itr)); |
| 54 | return {RESULT_SUCCESS, index}; | 55 | return {RESULT_SUCCESS, index}; |
| 55 | } | 56 | } |
| 56 | 57 | ||
| @@ -59,12 +60,12 @@ std::pair<ResultCode, Handle> Synchronization::WaitFor( | |||
| 59 | // If a timeout value of 0 was provided, just return the Timeout error code instead of | 60 | // If a timeout value of 0 was provided, just return the Timeout error code instead of |
| 60 | // suspending the thread. | 61 | // suspending the thread. |
| 61 | if (nano_seconds == 0) { | 62 | if (nano_seconds == 0) { |
| 62 | return {RESULT_TIMEOUT, 0}; | 63 | return {RESULT_TIMEOUT, InvalidHandle}; |
| 63 | } | 64 | } |
| 64 | 65 | ||
| 65 | if (thread->IsSyncCancelled()) { | 66 | if (thread->IsSyncCancelled()) { |
| 66 | thread->SetSyncCancelled(false); | 67 | thread->SetSyncCancelled(false); |
| 67 | return {ERR_SYNCHRONIZATION_CANCELED, 0}; | 68 | return {ERR_SYNCHRONIZATION_CANCELED, InvalidHandle}; |
| 68 | } | 69 | } |
| 69 | 70 | ||
| 70 | for (auto& object : sync_objects) { | 71 | for (auto& object : sync_objects) { |
| @@ -80,7 +81,7 @@ std::pair<ResultCode, Handle> Synchronization::WaitFor( | |||
| 80 | 81 | ||
| 81 | system.PrepareReschedule(thread->GetProcessorID()); | 82 | system.PrepareReschedule(thread->GetProcessorID()); |
| 82 | 83 | ||
| 83 | return {RESULT_TIMEOUT, 0}; | 84 | return {RESULT_TIMEOUT, InvalidHandle}; |
| 84 | } | 85 | } |
| 85 | 86 | ||
| 86 | } // namespace Kernel | 87 | } // namespace Kernel |