diff options
| author | 2018-08-05 16:24:43 -0400 | |
|---|---|---|
| committer | 2018-08-05 16:29:17 -0400 | |
| commit | 7a77d0a71e6e75d1f7af4649c5a03176f68860ab (patch) | |
| tree | 51ac17283ce07049b1908ea3bbcb9cf3d978eaea /src | |
| parent | Merge pull request #928 from MerryMage/dynarmic (diff) | |
| download | yuzu-7a77d0a71e6e75d1f7af4649c5a03176f68860ab.tar.gz yuzu-7a77d0a71e6e75d1f7af4649c5a03176f68860ab.tar.xz yuzu-7a77d0a71e6e75d1f7af4649c5a03176f68860ab.zip | |
address_arbiter: Return by value from GetThreadsWaitingOnAddress()
In all cases the vector being supplied is empty, so we can just return
by value in these instances.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/address_arbiter.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index 7a17ed162..03a954a9f 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp | |||
| @@ -32,9 +32,8 @@ static ResultCode WaitForAddress(VAddr address, s64 timeout) { | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | // Gets the threads waiting on an address. | 34 | // Gets the threads waiting on an address. |
| 35 | static void GetThreadsWaitingOnAddress(std::vector<SharedPtr<Thread>>& waiting_threads, | 35 | static std::vector<SharedPtr<Thread>> GetThreadsWaitingOnAddress(VAddr address) { |
| 36 | VAddr address) { | 36 | const auto RetrieveWaitingThreads = |
| 37 | auto RetrieveWaitingThreads = | ||
| 38 | [](size_t core_index, std::vector<SharedPtr<Thread>>& waiting_threads, VAddr arb_addr) { | 37 | [](size_t core_index, std::vector<SharedPtr<Thread>>& waiting_threads, VAddr arb_addr) { |
| 39 | const auto& scheduler = Core::System::GetInstance().Scheduler(core_index); | 38 | const auto& scheduler = Core::System::GetInstance().Scheduler(core_index); |
| 40 | auto& thread_list = scheduler->GetThreadList(); | 39 | auto& thread_list = scheduler->GetThreadList(); |
| @@ -45,16 +44,20 @@ static void GetThreadsWaitingOnAddress(std::vector<SharedPtr<Thread>>& waiting_t | |||
| 45 | } | 44 | } |
| 46 | }; | 45 | }; |
| 47 | 46 | ||
| 48 | // Retrieve a list of all threads that are waiting for this address. | 47 | // Retrieve all threads that are waiting for this address. |
| 49 | RetrieveWaitingThreads(0, waiting_threads, address); | 48 | std::vector<SharedPtr<Thread>> threads; |
| 50 | RetrieveWaitingThreads(1, waiting_threads, address); | 49 | RetrieveWaitingThreads(0, threads, address); |
| 51 | RetrieveWaitingThreads(2, waiting_threads, address); | 50 | RetrieveWaitingThreads(1, threads, address); |
| 52 | RetrieveWaitingThreads(3, waiting_threads, address); | 51 | RetrieveWaitingThreads(2, threads, address); |
| 52 | RetrieveWaitingThreads(3, threads, address); | ||
| 53 | |||
| 53 | // Sort them by priority, such that the highest priority ones come first. | 54 | // Sort them by priority, such that the highest priority ones come first. |
| 54 | std::sort(waiting_threads.begin(), waiting_threads.end(), | 55 | std::sort(threads.begin(), threads.end(), |
| 55 | [](const SharedPtr<Thread>& lhs, const SharedPtr<Thread>& rhs) { | 56 | [](const SharedPtr<Thread>& lhs, const SharedPtr<Thread>& rhs) { |
| 56 | return lhs->current_priority < rhs->current_priority; | 57 | return lhs->current_priority < rhs->current_priority; |
| 57 | }); | 58 | }); |
| 59 | |||
| 60 | return threads; | ||
| 58 | } | 61 | } |
| 59 | 62 | ||
| 60 | // Wake up num_to_wake (or all) threads in a vector. | 63 | // Wake up num_to_wake (or all) threads in a vector. |
| @@ -76,9 +79,7 @@ static void WakeThreads(std::vector<SharedPtr<Thread>>& waiting_threads, s32 num | |||
| 76 | 79 | ||
| 77 | // Signals an address being waited on. | 80 | // Signals an address being waited on. |
| 78 | ResultCode SignalToAddress(VAddr address, s32 num_to_wake) { | 81 | ResultCode SignalToAddress(VAddr address, s32 num_to_wake) { |
| 79 | // Get threads waiting on the address. | 82 | std::vector<SharedPtr<Thread>> waiting_threads = GetThreadsWaitingOnAddress(address); |
| 80 | std::vector<SharedPtr<Thread>> waiting_threads; | ||
| 81 | GetThreadsWaitingOnAddress(waiting_threads, address); | ||
| 82 | 83 | ||
| 83 | WakeThreads(waiting_threads, num_to_wake); | 84 | WakeThreads(waiting_threads, num_to_wake); |
| 84 | return RESULT_SUCCESS; | 85 | return RESULT_SUCCESS; |
| @@ -110,12 +111,11 @@ ResultCode ModifyByWaitingCountAndSignalToAddressIfEqual(VAddr address, s32 valu | |||
| 110 | } | 111 | } |
| 111 | 112 | ||
| 112 | // Get threads waiting on the address. | 113 | // Get threads waiting on the address. |
| 113 | std::vector<SharedPtr<Thread>> waiting_threads; | 114 | std::vector<SharedPtr<Thread>> waiting_threads = GetThreadsWaitingOnAddress(address); |
| 114 | GetThreadsWaitingOnAddress(waiting_threads, address); | ||
| 115 | 115 | ||
| 116 | // Determine the modified value depending on the waiting count. | 116 | // Determine the modified value depending on the waiting count. |
| 117 | s32 updated_value; | 117 | s32 updated_value; |
| 118 | if (waiting_threads.size() == 0) { | 118 | if (waiting_threads.empty()) { |
| 119 | updated_value = value - 1; | 119 | updated_value = value - 1; |
| 120 | } else if (num_to_wake <= 0 || waiting_threads.size() <= static_cast<u32>(num_to_wake)) { | 120 | } else if (num_to_wake <= 0 || waiting_threads.size() <= static_cast<u32>(num_to_wake)) { |
| 121 | updated_value = value + 1; | 121 | updated_value = value + 1; |