diff options
author | bunnei <bunneidev@gmail.com> | 2015-01-15 01:22:50 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2015-01-22 00:41:00 +0100 |
commit | c22bac6398ff1705992fc44b2c29775c84cff662 (patch) | |
tree | e20da7e6e1824c19b7ced73f43815397749ffae7 /src/core/hle/kernel/kernel.cpp | |
parent | Merge pull request #491 from archshift/hidspvr (diff) | |
download | yuzu-c22bac6398ff1705992fc44b2c29775c84cff662.tar yuzu-c22bac6398ff1705992fc44b2c29775c84cff662.tar.gz yuzu-c22bac6398ff1705992fc44b2c29775c84cff662.tar.bz2 yuzu-c22bac6398ff1705992fc44b2c29775c84cff662.tar.lz yuzu-c22bac6398ff1705992fc44b2c29775c84cff662.tar.xz yuzu-c22bac6398ff1705992fc44b2c29775c84cff662.tar.zst yuzu-c22bac6398ff1705992fc44b2c29775c84cff662.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/kernel.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index d3684896f..07e96e633 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -18,6 +18,32 @@ SharedPtr<Thread> g_main_thread = nullptr; 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()) { + waiting_threads.push_back(thread); + } +} + +Thread* WaitObject::ResumeNextThread() { + if (waiting_threads.empty()) return nullptr; + + auto next_thread = waiting_threads.front(); + + next_thread->ResumeFromWait(); + waiting_threads.erase(waiting_threads.begin()); + + return next_thread.get(); +} + +void WaitObject::ReleaseAllWaitingThreads() { + auto waiting_threads_copy = waiting_threads; + + for (auto thread : waiting_threads_copy) + thread->ReleaseWaitObject(this); + + waiting_threads.clear(); +} + HandleTable::HandleTable() { next_generation = 1; Clear(); |