summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar bunnei2018-01-07 16:33:41 -0500
committerGravatar bunnei2018-01-07 16:33:41 -0500
commit0f6fbdb9632d4d67695b4f151884434b91441782 (patch)
treeb3b112ae9c2cb47fe70bd889284efb1c6411abf7 /src/core/hle/kernel
parentnso: Always load the filepath specified by the user. (diff)
downloadyuzu-0f6fbdb9632d4d67695b4f151884434b91441782.tar.gz
yuzu-0f6fbdb9632d4d67695b4f151884434b91441782.tar.xz
yuzu-0f6fbdb9632d4d67695b4f151884434b91441782.zip
wait_object: Refactor to allow waking up a single thread.
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/wait_object.cpp37
-rw-r--r--src/core/hle/kernel/wait_object.h6
2 files changed, 28 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() {
67 return candidate; 67 return candidate;
68} 68}
69 69
70void WaitObject::WakeupAllWaitingThreads() { 70void WaitObject::WakeupWaitingThread(SharedPtr<Thread> thread) {
71 while (auto thread = GetHighestPriorityReadyThread()) { 71 if (!thread)
72 if (!thread->IsSleepingOnWaitAll()) { 72 return;
73 Acquire(thread.get()); 73
74 } else { 74 if (!thread->IsSleepingOnWaitAll()) {
75 for (auto& object : thread->wait_objects) { 75 Acquire(thread.get());
76 object->Acquire(thread.get()); 76 } else {
77 } 77 for (auto& object : thread->wait_objects) {
78 object->Acquire(thread.get());
78 } 79 }
80 }
79 81
80 // Invoke the wakeup callback before clearing the wait objects 82 // Invoke the wakeup callback before clearing the wait objects
81 if (thread->wakeup_callback) 83 if (thread->wakeup_callback)
82 thread->wakeup_callback(ThreadWakeupReason::Signal, thread, this); 84 thread->wakeup_callback(ThreadWakeupReason::Signal, thread, this);
83 85
84 for (auto& object : thread->wait_objects) 86 for (auto& object : thread->wait_objects)
85 object->RemoveWaitingThread(thread.get()); 87 object->RemoveWaitingThread(thread.get());
86 thread->wait_objects.clear(); 88 thread->wait_objects.clear();
87 89
88 thread->ResumeFromWait(); 90 thread->ResumeFromWait();
91}
92
93void WaitObject::WakeupAllWaitingThreads() {
94 while (auto thread = GetHighestPriorityReadyThread()) {
95 WakeupWaitingThread(thread);
89 } 96 }
90} 97}
91 98
diff --git a/src/core/hle/kernel/wait_object.h b/src/core/hle/kernel/wait_object.h
index 861578186..78bfd8c6c 100644
--- a/src/core/hle/kernel/wait_object.h
+++ b/src/core/hle/kernel/wait_object.h
@@ -44,6 +44,12 @@ public:
44 */ 44 */
45 virtual void WakeupAllWaitingThreads(); 45 virtual void WakeupAllWaitingThreads();
46 46
47 /**
48 * Wakes up a single thread waiting on this object.
49 * @param thread Thread that is waiting on this object to wakeup.
50 */
51 void WakeupWaitingThread(SharedPtr<Thread> thread);
52
47 /// Obtains the highest priority thread that is ready to run from this object's waiting list. 53 /// Obtains the highest priority thread that is ready to run from this object's waiting list.
48 SharedPtr<Thread> GetHighestPriorityReadyThread(); 54 SharedPtr<Thread> GetHighestPriorityReadyThread();
49 55