2021-04-01 06:06:02 +02:00
|
|
|
// 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));
|
|
|
|
}
|
|
|
|
|
2021-04-24 07:04:28 +02:00
|
|
|
size_t KAutoObjectWithListContainer::GetOwnedCount(KProcess* owner) {
|
2021-04-01 06:06:02 +02:00
|
|
|
KScopedLightLock lk(m_lock);
|
|
|
|
|
|
|
|
size_t count = 0;
|
|
|
|
|
|
|
|
for (auto& obj : m_object_list) {
|
|
|
|
if (obj.GetOwner() == owner) {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Kernel
|