IDM: Implement idm::clear<typename>

This commit is contained in:
Eladash 2020-05-07 17:15:06 +03:00 committed by Ivan
parent e1183f6919
commit f0d526411c
2 changed files with 10 additions and 28 deletions

View File

@ -218,34 +218,8 @@ error_code sceNpTrophyTerm()
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
}
u32 it = 0;
u32 ids[std::max(trophy_context_t::id_count, trophy_handle_t::id_count)];
const auto get_handles = [&](u32 id, trophy_handle_t&)
{
ids[it++] = id;
};
const auto get_contexts = [&](u32 id, trophy_context_t&)
{
ids[it++] = id;
};
// This functionality could be implemented in idm instead
idm::select<trophy_handle_t>(get_handles);
while (it)
{
idm::remove<trophy_handle_t>(ids[--it]);
}
it = 0;
idm::select<trophy_context_t>(get_contexts);
while (it)
{
idm::remove<trophy_context_t>(ids[--it]);
}
idm::clear<trophy_context_t>();
idm::clear<trophy_handle_t>();
trophy_manager->is_initialized = false;

View File

@ -323,6 +323,14 @@ public:
// Remove all objects
static void clear();
// Remove all objects of a type
template <typename T>
static inline void clear()
{
std::lock_guard lock(id_manager::g_mutex);
g_map[id_manager::typeinfo::get_index<T>()].clear();
}
// Get last ID (updated in create_id/allocate_id)
static inline u32 last_id()
{