diff options
| author | 2015-01-21 21:09:47 -0500 | |
|---|---|---|
| committer | 2015-01-21 21:09:47 -0500 | |
| commit | 24a63662ba6c7816001bba399e85d8c131a89489 (patch) | |
| tree | a9959e69723b4f19550834171c962ec06c9e34b7 /src/core/hle/kernel/kernel.cpp | |
| parent | Merge pull request #491 from archshift/hidspvr (diff) | |
| parent | WaitSynchronization: Added a result code for invalid result, fixed bug. (diff) | |
| download | yuzu-24a63662ba6c7816001bba399e85d8c131a89489.tar.gz yuzu-24a63662ba6c7816001bba399e85d8c131a89489.tar.xz yuzu-24a63662ba6c7816001bba399e85d8c131a89489.zip | |
Merge pull request #495 from bunnei/fix-waitsynch
Fix WaitSynchronization
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index d3684896f..d7fa4dcea 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -18,6 +18,41 @@ SharedPtr<Thread> g_main_thread = nullptr; | |||
| 18 | HandleTable g_handle_table; | 18 | HandleTable g_handle_table; |
| 19 | u64 g_program_id = 0; | 19 | u64 g_program_id = 0; |
| 20 | 20 | ||
| 21 | void WaitObject::AddWaitingThread(Thread* thread) { | ||
| 22 | auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); | ||
| 23 | if (itr == waiting_threads.end()) | ||
| 24 | waiting_threads.push_back(thread); | ||
| 25 | } | ||
| 26 | |||
| 27 | void WaitObject::RemoveWaitingThread(Thread* thread) { | ||
| 28 | auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); | ||
| 29 | if (itr != waiting_threads.end()) | ||
| 30 | waiting_threads.erase(itr); | ||
| 31 | } | ||
| 32 | |||
| 33 | Thread* WaitObject::WakeupNextThread() { | ||
| 34 | if (waiting_threads.empty()) | ||
| 35 | return nullptr; | ||
| 36 | |||
| 37 | auto next_thread = waiting_threads.front(); | ||
| 38 | waiting_threads.erase(waiting_threads.begin()); | ||
| 39 | |||
| 40 | next_thread->ReleaseWaitObject(this); | ||
| 41 | |||
| 42 | return next_thread; | ||
| 43 | } | ||
| 44 | |||
| 45 | void WaitObject::WakeupAllWaitingThreads() { | ||
| 46 | auto waiting_threads_copy = waiting_threads; | ||
| 47 | |||
| 48 | // We use a copy because ReleaseWaitObject will remove the thread from this object's | ||
| 49 | // waiting_threads list | ||
| 50 | for (auto thread : waiting_threads_copy) | ||
| 51 | thread->ReleaseWaitObject(this); | ||
| 52 | |||
| 53 | _assert_msg_(Kernel, waiting_threads.empty(), "failed to awaken all waiting threads!"); | ||
| 54 | } | ||
| 55 | |||
| 21 | HandleTable::HandleTable() { | 56 | HandleTable::HandleTable() { |
| 22 | next_generation = 1; | 57 | next_generation = 1; |
| 23 | Clear(); | 58 | Clear(); |