mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 03:32:55 +00:00
Deprecate fxm::get_always
And also its unused fxm::import_always counterpart
This commit is contained in:
parent
4ec3e968ff
commit
fcbf91b7cb
@ -679,57 +679,6 @@ public:
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Emplace the object return by provider() (old object will be removed if it exists)
|
||||
template <typename T, typename F, typename... Args>
|
||||
static auto import_always(F&& provider, Args&&... args) -> decltype(static_cast<std::shared_ptr<T>>(provider(std::forward<Args>(args)...)))
|
||||
{
|
||||
std::shared_ptr<T> ptr;
|
||||
std::shared_ptr<void> old;
|
||||
{
|
||||
std::lock_guard lock(id_manager::g_mutex);
|
||||
|
||||
auto& cur = g_vec[get_type<T>()];
|
||||
|
||||
ptr = provider(std::forward<Args>(args)...);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
old = std::move(cur);
|
||||
cur = ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Get the object unconditionally (create an object if it doesn't exist)
|
||||
template <typename T, typename Make = T, typename... Args>
|
||||
static std::enable_if_t<std::is_constructible<Make, Args...>::value, std::shared_ptr<T>> get_always(Args&&... args)
|
||||
{
|
||||
std::shared_ptr<T> ptr;
|
||||
{
|
||||
std::lock_guard lock(id_manager::g_mutex);
|
||||
|
||||
auto& old = g_vec[get_type<T>()];
|
||||
|
||||
if (old)
|
||||
{
|
||||
return {old, static_cast<T*>(old.get())};
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = std::make_shared<Make>(std::forward<Args>(args)...);
|
||||
old = ptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Unsafe version of check(), can be used in some cases
|
||||
template <typename T>
|
||||
static inline T* check_unlocked()
|
||||
|
Loading…
x
Reference in New Issue
Block a user