diff options
author | bunnei <bunneidev@gmail.com> | 2021-11-10 04:02:11 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2021-12-07 01:39:17 +0100 |
commit | bc1399204b914608715306a8a8dbe2f201dd4365 (patch) | |
tree | 7799195284bb20b15cd6be6addea57f45364136f /src/core/hle/kernel/k_synchronization_object.h | |
parent | core: hle: kernel: Disable dispatch count tracking on single core. (diff) | |
download | yuzu-bc1399204b914608715306a8a8dbe2f201dd4365.tar yuzu-bc1399204b914608715306a8a8dbe2f201dd4365.tar.gz yuzu-bc1399204b914608715306a8a8dbe2f201dd4365.tar.bz2 yuzu-bc1399204b914608715306a8a8dbe2f201dd4365.tar.lz yuzu-bc1399204b914608715306a8a8dbe2f201dd4365.tar.xz yuzu-bc1399204b914608715306a8a8dbe2f201dd4365.tar.zst yuzu-bc1399204b914608715306a8a8dbe2f201dd4365.zip |
Diffstat (limited to '')
-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; |