diff options
| author | bunnei <bunneidev@gmail.com> | 2018-01-07 16:33:41 -0500 |
|---|---|---|
| committer | bunnei <bunneidev@gmail.com> | 2018-01-07 16:33:41 -0500 |
| commit | 0f6fbdb9632d4d67695b4f151884434b91441782 (patch) | |
| tree | b3b112ae9c2cb47fe70bd889284efb1c6411abf7 /src/core/hle/kernel/wait_object.cpp | |
| parent | bc77a7580ee675d4e0ac220c63835258b2a87d41 (diff) | |
wait_object: Refactor to allow waking up a single thread.
Diffstat (limited to 'src/core/hle/kernel/wait_object.cpp')
| -rw-r--r-- | src/core/hle/kernel/wait_object.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp index 469554908..c942a40fa 100644 --- a/src/core/hle/kernel/wait_object.cpp +++ b/src/core/hle/kernel/wait_object.cpp @@ -67,25 +67,32 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() { return candidate; } -void WaitObject::WakeupAllWaitingThreads() { - while (auto thread = GetHighestPriorityReadyThread()) { - if (!thread->IsSleepingOnWaitAll()) { - Acquire(thread.get()); - } else { - for (auto& object : thread->wait_objects) { - object->Acquire(thread.get()); - } +void WaitObject::WakeupWaitingThread(SharedPtr<Thread> thread) { + if (!thread) + return; + + if (!thread->IsSleepingOnWaitAll()) { + Acquire(thread.get()); + } else { + for (auto& object : thread->wait_objects) { + object->Acquire(thread.get()); } + } - // Invoke the wakeup callback before clearing the wait objects - if (thread->wakeup_callback) - thread->wakeup_callback(ThreadWakeupReason::Signal, thread, this); + // Invoke the wakeup callback before clearing the wait objects + if (thread->wakeup_callback) + thread->wakeup_callback(ThreadWakeupReason::Signal, thread, this); - for (auto& object : thread->wait_objects) - object->RemoveWaitingThread(thread.get()); - thread->wait_objects.clear(); + for (auto& object : thread->wait_objects) + object->RemoveWaitingThread(thread.get()); + thread->wait_objects.clear(); - thread->ResumeFromWait(); + thread->ResumeFromWait(); +} + +void WaitObject::WakeupAllWaitingThreads() { + while (auto thread = GetHighestPriorityReadyThread()) { + WakeupWaitingThread(thread); } } |
