mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-16 16:21:02 +00:00
Finally remove fxm from IdManager
This commit is contained in:
parent
c065a21b74
commit
465b16e786
@ -122,7 +122,7 @@ static_assert(sizeof(sys_config_padmanager_data_t) == 26);
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global (fxm-managed) sys_config state
|
* Global sys_config state
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class lv2_config
|
class lv2_config
|
||||||
|
@ -6,7 +6,6 @@ shared_mutex id_manager::g_mutex;
|
|||||||
|
|
||||||
thread_local DECLARE(idm::g_id);
|
thread_local DECLARE(idm::g_id);
|
||||||
DECLARE(idm::g_map);
|
DECLARE(idm::g_map);
|
||||||
DECLARE(fxm::g_vec);
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -68,19 +67,3 @@ void idm::clear()
|
|||||||
map.clear();
|
map.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fxm::init()
|
|
||||||
{
|
|
||||||
// Allocate
|
|
||||||
g_vec.resize(id_manager::typeinfo::get_count());
|
|
||||||
fxm::clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fxm::clear()
|
|
||||||
{
|
|
||||||
// Call recorded finalization functions for all IDs
|
|
||||||
for (auto& val : g_vec)
|
|
||||||
{
|
|
||||||
val.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -588,132 +588,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Object manager for emulated process. One unique object per type, or zero.
|
|
||||||
class fxm
|
|
||||||
{
|
|
||||||
// Type Index -> Object. Use global since only one process is supported atm.
|
|
||||||
static std::vector<std::shared_ptr<void>> g_vec;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static inline u32 get_type()
|
|
||||||
{
|
|
||||||
return id_manager::typeinfo::get_index<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Initialize object manager
|
|
||||||
static void init();
|
|
||||||
|
|
||||||
// Remove all objects
|
|
||||||
static void clear();
|
|
||||||
|
|
||||||
// Create the object (returns nullptr if it already exists)
|
|
||||||
template <typename T, typename Make = T, typename... Args>
|
|
||||||
static std::enable_if_t<std::is_constructible<Make, Args...>::value, std::shared_ptr<T>> make(Args&&... args)
|
|
||||||
{
|
|
||||||
std::shared_ptr<T> ptr;
|
|
||||||
{
|
|
||||||
std::lock_guard lock(id_manager::g_mutex);
|
|
||||||
|
|
||||||
auto& cur = g_vec[get_type<T>()];
|
|
||||||
|
|
||||||
if (!cur)
|
|
||||||
{
|
|
||||||
ptr = std::make_shared<Make>(std::forward<Args>(args)...);
|
|
||||||
cur = ptr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emplace the object returned by provider() and return it if no object exists
|
|
||||||
template <typename T, typename F, typename... Args>
|
|
||||||
static auto import(F&& provider, Args&&... args) -> decltype(static_cast<std::shared_ptr<T>>(provider(std::forward<Args>(args)...)))
|
|
||||||
{
|
|
||||||
std::shared_ptr<T> ptr;
|
|
||||||
{
|
|
||||||
std::lock_guard lock(id_manager::g_mutex);
|
|
||||||
|
|
||||||
auto& cur = g_vec[get_type<T>()];
|
|
||||||
|
|
||||||
if (!cur)
|
|
||||||
{
|
|
||||||
ptr = provider(std::forward<Args>(args)...);
|
|
||||||
|
|
||||||
if (ptr)
|
|
||||||
{
|
|
||||||
cur = ptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ptr)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unsafe version of check(), can be used in some cases
|
|
||||||
template <typename T>
|
|
||||||
static inline T* check_unlocked()
|
|
||||||
{
|
|
||||||
return static_cast<T*>(g_vec[get_type<T>()].get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check whether the object exists
|
|
||||||
template <typename T>
|
|
||||||
static inline T* check()
|
|
||||||
{
|
|
||||||
reader_lock lock(id_manager::g_mutex);
|
|
||||||
|
|
||||||
return check_unlocked<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the object (returns nullptr if it doesn't exist)
|
|
||||||
template <typename T>
|
|
||||||
static inline std::shared_ptr<T> get()
|
|
||||||
{
|
|
||||||
reader_lock lock(id_manager::g_mutex);
|
|
||||||
|
|
||||||
auto& ptr = g_vec[get_type<T>()];
|
|
||||||
|
|
||||||
return {ptr, static_cast<T*>(ptr.get())};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the object
|
|
||||||
template <typename T>
|
|
||||||
static inline bool remove()
|
|
||||||
{
|
|
||||||
std::shared_ptr<void> ptr;
|
|
||||||
{
|
|
||||||
std::lock_guard lock(id_manager::g_mutex);
|
|
||||||
ptr = std::move(g_vec[get_type<T>()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ptr.operator bool();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the object and return it
|
|
||||||
template <typename T>
|
|
||||||
static inline std::shared_ptr<T> withdraw()
|
|
||||||
{
|
|
||||||
std::shared_ptr<void> ptr;
|
|
||||||
{
|
|
||||||
std::lock_guard lock(id_manager::g_mutex);
|
|
||||||
ptr = std::move(g_vec[get_type<T>()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {ptr, static_cast<T*>(ptr.get())};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#include "util/fixed_typemap.hpp"
|
#include "util/fixed_typemap.hpp"
|
||||||
|
|
||||||
extern stx::manual_fixed_typemap<void> g_fixed_typemap;
|
extern stx::manual_fixed_typemap<void> g_fixed_typemap;
|
||||||
|
@ -322,7 +322,6 @@ void Emulator::Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
idm::init();
|
idm::init();
|
||||||
fxm::init();
|
|
||||||
g_fxo->reset();
|
g_fxo->reset();
|
||||||
|
|
||||||
// Reset defaults, cache them
|
// Reset defaults, cache them
|
||||||
@ -1791,7 +1790,6 @@ void Emulator::Stop(bool restart)
|
|||||||
|
|
||||||
lv2_obj::cleanup();
|
lv2_obj::cleanup();
|
||||||
idm::clear();
|
idm::clear();
|
||||||
fxm::clear();
|
|
||||||
g_fxo->reset();
|
g_fxo->reset();
|
||||||
|
|
||||||
LOG_NOTICE(GENERAL, "Objects cleared...");
|
LOG_NOTICE(GENERAL, "Objects cleared...");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user