diff options
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 4729a7fe0..64166ab99 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -37,6 +37,10 @@ void Thread::Acquire() { | |||
| 37 | ASSERT_MSG(!ShouldWait(), "object unavailable!"); | 37 | ASSERT_MSG(!ShouldWait(), "object unavailable!"); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | // TODO(yuriks): This can be removed if Thread objects are explicitly pooled in the future, allowing | ||
| 41 | // us to simply use a pool index or similar. | ||
| 42 | static Kernel::HandleTable wakeup_callback_handle_table; | ||
| 43 | |||
| 40 | // Lists all thread ids that aren't deleted/etc. | 44 | // Lists all thread ids that aren't deleted/etc. |
| 41 | static std::vector<SharedPtr<Thread>> thread_list; | 45 | static std::vector<SharedPtr<Thread>> thread_list; |
| 42 | 46 | ||
| @@ -93,6 +97,8 @@ void Thread::Stop() { | |||
| 93 | 97 | ||
| 94 | // Cancel any outstanding wakeup events for this thread | 98 | // Cancel any outstanding wakeup events for this thread |
| 95 | CoreTiming::UnscheduleEvent(ThreadWakeupEventType, callback_handle); | 99 | CoreTiming::UnscheduleEvent(ThreadWakeupEventType, callback_handle); |
| 100 | wakeup_callback_handle_table.Close(callback_handle); | ||
| 101 | callback_handle = 0; | ||
| 96 | 102 | ||
| 97 | // Clean up thread from ready queue | 103 | // Clean up thread from ready queue |
| 98 | // This is only needed when the thread is termintated forcefully (SVC TerminateProcess) | 104 | // This is only needed when the thread is termintated forcefully (SVC TerminateProcess) |
| @@ -108,6 +114,7 @@ void Thread::Stop() { | |||
| 108 | for (auto& wait_object : wait_objects) { | 114 | for (auto& wait_object : wait_objects) { |
| 109 | wait_object->RemoveWaitingThread(this); | 115 | wait_object->RemoveWaitingThread(this); |
| 110 | } | 116 | } |
| 117 | wait_objects.clear(); | ||
| 111 | 118 | ||
| 112 | Kernel::g_current_process->used_tls_slots[tls_index] = false; | 119 | Kernel::g_current_process->used_tls_slots[tls_index] = false; |
| 113 | 120 | ||
| @@ -268,10 +275,6 @@ void WaitCurrentThread_ArbitrateAddress(VAddr wait_address) { | |||
| 268 | thread->status = THREADSTATUS_WAIT_ARB; | 275 | thread->status = THREADSTATUS_WAIT_ARB; |
| 269 | } | 276 | } |
| 270 | 277 | ||
| 271 | // TODO(yuriks): This can be removed if Thread objects are explicitly pooled in the future, allowing | ||
| 272 | // us to simply use a pool index or similar. | ||
| 273 | static Kernel::HandleTable wakeup_callback_handle_table; | ||
| 274 | |||
| 275 | /** | 278 | /** |
| 276 | * Callback that will wake up the thread it was scheduled for | 279 | * Callback that will wake up the thread it was scheduled for |
| 277 | * @param thread_handle The handle of the thread that's been awoken | 280 | * @param thread_handle The handle of the thread that's been awoken |
| @@ -503,12 +506,16 @@ void ThreadingInit() { | |||
| 503 | 506 | ||
| 504 | current_thread = nullptr; | 507 | current_thread = nullptr; |
| 505 | next_thread_id = 1; | 508 | next_thread_id = 1; |
| 506 | |||
| 507 | thread_list.clear(); | ||
| 508 | ready_queue.clear(); | ||
| 509 | } | 509 | } |
| 510 | 510 | ||
| 511 | void ThreadingShutdown() { | 511 | void ThreadingShutdown() { |
| 512 | current_thread = nullptr; | ||
| 513 | |||
| 514 | for (auto& t : thread_list) { | ||
| 515 | t->Stop(); | ||
| 516 | } | ||
| 517 | thread_list.clear(); | ||
| 518 | ready_queue.clear(); | ||
| 512 | } | 519 | } |
| 513 | 520 | ||
| 514 | } // namespace | 521 | } // namespace |