yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

wait_object: Refactor to allow waking up a single thread.

This commit is contained in:
bunnei 2018-01-07 16:33:41 -05:00
parent bc77a7580e
commit 0f6fbdb963
2 changed files with 30 additions and 17 deletions

View File

@ -67,8 +67,10 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
return candidate;
}
void WaitObject::WakeupAllWaitingThreads() {
while (auto thread = GetHighestPriorityReadyThread()) {
void WaitObject::WakeupWaitingThread(SharedPtr<Thread> thread) {
if (!thread)
return;
if (!thread->IsSleepingOnWaitAll()) {
Acquire(thread.get());
} else {
@ -87,6 +89,11 @@ void WaitObject::WakeupAllWaitingThreads() {
thread->ResumeFromWait();
}
void WaitObject::WakeupAllWaitingThreads() {
while (auto thread = GetHighestPriorityReadyThread()) {
WakeupWaitingThread(thread);
}
}
const std::vector<SharedPtr<Thread>>& WaitObject::GetWaitingThreads() const {

View File

@ -44,6 +44,12 @@ public:
*/
virtual void WakeupAllWaitingThreads();
/**
* Wakes up a single thread waiting on this object.
* @param thread Thread that is waiting on this object to wakeup.
*/
void WakeupWaitingThread(SharedPtr<Thread> thread);
/// Obtains the highest priority thread that is ready to run from this object's waiting list.
SharedPtr<Thread> GetHighestPriorityReadyThread();