diff options
| author | bunnei <bunneidev@gmail.com> | 2021-11-09 19:02:11 -0800 |
|---|---|---|
| committer | bunnei <bunneidev@gmail.com> | 2021-12-06 16:39:17 -0800 |
| commit | bc1399204b914608715306a8a8dbe2f201dd4365 (patch) | |
| tree | 7799195284bb20b15cd6be6addea57f45364136f /src/core/hle/kernel/k_synchronization_object.h | |
| parent | 3dc803a430107fb22ffc91608c613e09ec5c8b51 (diff) | |
hle: kernel: Update KThreadQueue and migrate KSynchronizationObject.
Diffstat (limited to 'src/core/hle/kernel/k_synchronization_object.h')
| -rw-r--r-- | src/core/hle/kernel/k_synchronization_object.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_synchronization_object.h b/src/core/hle/kernel/k_synchronization_object.h index 898e58e16..789ff4780 100644 --- a/src/core/hle/kernel/k_synchronization_object.h +++ b/src/core/hle/kernel/k_synchronization_object.h @@ -35,6 +35,38 @@ public: [[nodiscard]] std::vector<KThread*> GetWaitingThreadsForDebugging() const; + void LinkNode(ThreadListNode* node) { + // Link the node to the list. + if (thread_list_tail == nullptr) { + thread_list_head = node; + } else { + thread_list_tail->next = node; + } + + thread_list_tail = node; + } + + void UnlinkNode(ThreadListNode* node) { + // Unlink the node from the list. + ThreadListNode* prev_ptr = + reinterpret_cast<ThreadListNode*>(std::addressof(thread_list_head)); + ThreadListNode* prev_val = nullptr; + ThreadListNode *prev, *tail_prev; + + do { + prev = prev_ptr; + prev_ptr = prev_ptr->next; + tail_prev = prev_val; + prev_val = prev_ptr; + } while (prev_ptr != node); + + if (thread_list_tail == node) { + thread_list_tail = tail_prev; + } + + prev->next = node->next; + } + protected: explicit KSynchronizationObject(KernelCore& kernel); ~KSynchronizationObject() override; |
