mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 06:26:49 +00:00
idm: Implement creation/destruction invalidation counter
* "Ensures" newely created IDs won't have the same ID as old destroyed objects for lv2_obj. (256 tries cycle) Similar to how the kernel implements it.
This commit is contained in:
parent
224a0e4b1a
commit
3265772ae4
5 changed files with 44 additions and 17 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "IdManager.h"
|
||||
#include "Utilities/Thread.h"
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ shared_mutex id_manager::g_mutex;
|
|||
thread_local DECLARE(idm::g_id);
|
||||
DECLARE(idm::g_map);
|
||||
|
||||
id_manager::id_map::pointer idm::allocate_id(const id_manager::id_key& info, u32 base, u32 step, u32 count)
|
||||
id_manager::id_map::pointer idm::allocate_id(const id_manager::id_key& info, u32 base, u32 step, u32 count, std::pair<u32, u32> invl_range)
|
||||
{
|
||||
// Base type id is stored in value
|
||||
auto& vec = g_map[info.value()];
|
||||
|
|
@ -32,8 +32,10 @@ id_manager::id_map::pointer idm::allocate_id(const id_manager::id_key& info, u32
|
|||
// Look for free ID
|
||||
if (!ptr->second)
|
||||
{
|
||||
g_id = next;
|
||||
ptr->first = id_manager::id_key(next, info.type());
|
||||
// Incremenet ID invalidation counter
|
||||
const u32 id = next | ((ptr->first + (1u << invl_range.first)) & (invl_range.second ? (((1u << invl_range.second) - 1) << invl_range.first) : 0));
|
||||
g_id = id;
|
||||
ptr->first = id_manager::id_key(id, info.type());
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue