summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_auto_object_container.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-01 06:06:02 +0200
committerbunnei <bunneidev@gmail.com>2021-05-06 01:40:49 +0200
commit34ce1dd7c724a4014ba4f8e7719f12352d0fddcb (patch)
tree574b3b57fb60233bd0cf6ef74eff49fe187f78ab /src/core/hle/kernel/k_auto_object_container.cpp
parenthle: kernel: Add initial impl. of KAutoObject. (diff)
downloadyuzu-34ce1dd7c724a4014ba4f8e7719f12352d0fddcb.tar
yuzu-34ce1dd7c724a4014ba4f8e7719f12352d0fddcb.tar.gz
yuzu-34ce1dd7c724a4014ba4f8e7719f12352d0fddcb.tar.bz2
yuzu-34ce1dd7c724a4014ba4f8e7719f12352d0fddcb.tar.lz
yuzu-34ce1dd7c724a4014ba4f8e7719f12352d0fddcb.tar.xz
yuzu-34ce1dd7c724a4014ba4f8e7719f12352d0fddcb.tar.zst
yuzu-34ce1dd7c724a4014ba4f8e7719f12352d0fddcb.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/k_auto_object_container.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_auto_object_container.cpp b/src/core/hle/kernel/k_auto_object_container.cpp
new file mode 100644
index 000000000..9ba8a54c7
--- /dev/null
+++ b/src/core/hle/kernel/k_auto_object_container.cpp
@@ -0,0 +1,35 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "core/hle/kernel/k_auto_object_container.h"
+
+namespace Kernel {
+
+void KAutoObjectWithListContainer::Register(KAutoObjectWithList* obj) {
+ KScopedLightLock lk(m_lock);
+
+ m_object_list.insert(*obj);
+}
+
+void KAutoObjectWithListContainer::Unregister(KAutoObjectWithList* obj) {
+ KScopedLightLock lk(m_lock);
+
+ m_object_list.erase(m_object_list.iterator_to(*obj));
+}
+
+size_t KAutoObjectWithListContainer::GetOwnedCount(Process* owner) {
+ KScopedLightLock lk(m_lock);
+
+ size_t count = 0;
+
+ for (auto& obj : m_object_list) {
+ if (obj.GetOwner() == owner) {
+ count++;
+ }
+ }
+
+ return count;
+}
+
+} // namespace Kernel