summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_auto_object_container.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/k_auto_object_container.cpp')
-rw-r--r--src/core/hle/kernel/k_auto_object_container.cpp28
1 files changed, 28 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..fc0c28874
--- /dev/null
+++ b/src/core/hle/kernel/k_auto_object_container.cpp
@@ -0,0 +1,28 @@
+// 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(KProcess* owner) {
+ KScopedLightLock lk(m_lock);
+
+ return std::count_if(m_object_list.begin(), m_object_list.end(),
+ [&](const auto& obj) { return obj.GetOwner() == owner; });
+}
+
+} // namespace Kernel