2022-04-23 10:59:50 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2021-04-01 06:06:02 +02:00
|
|
|
|
2021-09-30 22:11:47 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
2021-04-01 06:06:02 +02:00
|
|
|
#include "core/hle/kernel/k_auto_object_container.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
void KAutoObjectWithListContainer::Register(KAutoObjectWithList* obj) {
|
|
|
|
KScopedLightLock lk(m_lock);
|
|
|
|
|
2021-06-07 00:39:11 +02:00
|
|
|
m_object_list.insert_unique(*obj);
|
2021-04-01 06:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void KAutoObjectWithListContainer::Unregister(KAutoObjectWithList* obj) {
|
|
|
|
KScopedLightLock lk(m_lock);
|
|
|
|
|
2021-06-07 00:39:11 +02:00
|
|
|
m_object_list.erase(*obj);
|
2021-04-01 06:06:02 +02:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2021-05-01 21:36:48 +02:00
|
|
|
return std::count_if(m_object_list.begin(), m_object_list.end(),
|
|
|
|
[&](const auto& obj) { return obj.GetOwner() == owner; });
|
2021-04-01 06:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Kernel
|