mirror of
https://github.com/PabloMK7/citra.git
synced 2024-12-01 19:59:38 +00:00
HLE/AddressArbiter: Remove threads that were awoken by timeout from the arbiter's waitlist when using WaitIfLessThanWithTimeout and DecrementAndWaitIfLessThanWithTimeout.
Fixes a regression introduced in #3096
This commit is contained in:
parent
81fbe06915
commit
8c16b90eae
1 changed files with 11 additions and 0 deletions
|
@ -77,6 +77,15 @@ SharedPtr<AddressArbiter> AddressArbiter::Create(std::string name) {
|
||||||
|
|
||||||
ResultCode AddressArbiter::ArbitrateAddress(SharedPtr<Thread> thread, ArbitrationType type,
|
ResultCode AddressArbiter::ArbitrateAddress(SharedPtr<Thread> thread, ArbitrationType type,
|
||||||
VAddr address, s32 value, u64 nanoseconds) {
|
VAddr address, s32 value, u64 nanoseconds) {
|
||||||
|
|
||||||
|
auto timeout_callback = [this](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
||||||
|
SharedPtr<WaitObject> object) {
|
||||||
|
ASSERT(reason == ThreadWakeupReason::Timeout);
|
||||||
|
// Remove the newly-awakened thread from the Arbiter's waiting list.
|
||||||
|
waiting_threads.erase(std::remove(waiting_threads.begin(), waiting_threads.end(), thread),
|
||||||
|
waiting_threads.end());
|
||||||
|
};
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
||||||
// Signal thread(s) waiting for arbitrate address...
|
// Signal thread(s) waiting for arbitrate address...
|
||||||
|
@ -99,6 +108,7 @@ ResultCode AddressArbiter::ArbitrateAddress(SharedPtr<Thread> thread, Arbitratio
|
||||||
break;
|
break;
|
||||||
case ArbitrationType::WaitIfLessThanWithTimeout:
|
case ArbitrationType::WaitIfLessThanWithTimeout:
|
||||||
if ((s32)Memory::Read32(address) < value) {
|
if ((s32)Memory::Read32(address) < value) {
|
||||||
|
thread->wakeup_callback = timeout_callback;
|
||||||
thread->WakeAfterDelay(nanoseconds);
|
thread->WakeAfterDelay(nanoseconds);
|
||||||
WaitThread(std::move(thread), address);
|
WaitThread(std::move(thread), address);
|
||||||
}
|
}
|
||||||
|
@ -117,6 +127,7 @@ ResultCode AddressArbiter::ArbitrateAddress(SharedPtr<Thread> thread, Arbitratio
|
||||||
if (memory_value < value) {
|
if (memory_value < value) {
|
||||||
// Only change the memory value if the thread should wait
|
// Only change the memory value if the thread should wait
|
||||||
Memory::Write32(address, (s32)memory_value - 1);
|
Memory::Write32(address, (s32)memory_value - 1);
|
||||||
|
thread->wakeup_callback = timeout_callback;
|
||||||
thread->WakeAfterDelay(nanoseconds);
|
thread->WakeAfterDelay(nanoseconds);
|
||||||
WaitThread(std::move(thread), address);
|
WaitThread(std::move(thread), address);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue