Deprecate fxm::get_always

And also its unused fxm::import_always counterpart
This commit is contained in:
Nekotekina 2019-08-25 17:28:54 +03:00
parent 4ec3e968ff
commit fcbf91b7cb
1 changed files with 0 additions and 51 deletions

View File

@ -679,57 +679,6 @@ public:
return ptr; 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 // Unsafe version of check(), can be used in some cases
template <typename T> template <typename T>
static inline T* check_unlocked() static inline T* check_unlocked()