summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2015-01-15 05:19:22 +0100
committerbunnei <bunneidev@gmail.com>2015-01-22 00:41:58 +0100
commit5e77e2e1de73ce7786f52f2a74c28182fa4aa845 (patch)
treed874f351cd8bc11757d50deba4fea1abefd323d2 /src
parentKernel: Added WaitObject and changed "waitable" objects inherit from it. (diff)
downloadyuzu-5e77e2e1de73ce7786f52f2a74c28182fa4aa845.tar
yuzu-5e77e2e1de73ce7786f52f2a74c28182fa4aa845.tar.gz
yuzu-5e77e2e1de73ce7786f52f2a74c28182fa4aa845.tar.bz2
yuzu-5e77e2e1de73ce7786f52f2a74c28182fa4aa845.tar.lz
yuzu-5e77e2e1de73ce7786f52f2a74c28182fa4aa845.tar.xz
yuzu-5e77e2e1de73ce7786f52f2a74c28182fa4aa845.tar.zst
yuzu-5e77e2e1de73ce7786f52f2a74c28182fa4aa845.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/kernel.cpp13
-rw-r--r--src/core/hle/kernel/kernel.h8
2 files changed, 17 insertions, 4 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 07e96e633..1dba85939 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -19,13 +19,20 @@ HandleTable g_handle_table;
u64 g_program_id = 0;
void WaitObject::AddWaitingThread(Thread* thread) {
- if (std::find(waiting_threads.begin(), waiting_threads.end(), thread) == waiting_threads.end()) {
+ auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread);
+ if (itr == waiting_threads.end())
waiting_threads.push_back(thread);
- }
+}
+
+void WaitObject::RemoveWaitingThread(Thread* thread) {
+ auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread);
+ if (itr != waiting_threads.end())
+ waiting_threads.erase(itr);
}
Thread* WaitObject::ResumeNextThread() {
- if (waiting_threads.empty()) return nullptr;
+ if (waiting_threads.empty())
+ return nullptr;
auto next_thread = waiting_threads.front();
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index a9af9de88..53b3f9143 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -105,7 +105,13 @@ public:
void AddWaitingThread(Thread* thread);
/**
- * Resumes the next thread waiting on this object
+ * Removes a thread from waiting on this object (e.g. if it was resumed already)
+ * @param thread Pointer to thread to remove
+ */
+ void RemoveWaitingThread(Thread* thead);
+
+ /**
+ * Resumes (and removes) the next thread waiting on this object
* @return Pointer to the thread that was resumed, nullptr if no threads are waiting
*/
Thread* ResumeNextThread();