mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-29 22:20:48 +00:00
shared_ptr.hpp: add trivial conversion for shared/single types
These conversions don't exist in std::shared_ptr-alike types. But I don't want to bother with == operators until we have proper C++20. Removed trivial conversion for atomic_ptr because it's heavyweight.
This commit is contained in:
parent
3a0b3a85a5
commit
77aa9e58f2
@ -2250,7 +2250,13 @@ std::string thread_ctrl::get_name_cached()
|
|||||||
|
|
||||||
if (!_this->m_tname.is_equal(name_cache)) [[unlikely]]
|
if (!_this->m_tname.is_equal(name_cache)) [[unlikely]]
|
||||||
{
|
{
|
||||||
name_cache = _this->m_tname.load();
|
_this->m_tname.peek_op([&](const shared_ptr<std::string>& ptr)
|
||||||
|
{
|
||||||
|
if (ptr != name_cache)
|
||||||
|
{
|
||||||
|
name_cache = ptr;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return *name_cache;
|
return *name_cache;
|
||||||
|
@ -1049,7 +1049,13 @@ void ppu_thread::fast_call(u32 addr, u32 rtoc)
|
|||||||
|
|
||||||
if (!_this->ppu_tname.is_equal(name_cache)) [[unlikely]]
|
if (!_this->ppu_tname.is_equal(name_cache)) [[unlikely]]
|
||||||
{
|
{
|
||||||
name_cache = _this->ppu_tname.load();
|
_this->ppu_tname.peek_op([&](const shared_ptr<std::string>& ptr)
|
||||||
|
{
|
||||||
|
if (ptr != name_cache)
|
||||||
|
{
|
||||||
|
name_cache = ptr;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto cia = _this->cia;
|
const auto cia = _this->cia;
|
||||||
|
@ -1615,7 +1615,13 @@ void spu_thread::cpu_task()
|
|||||||
|
|
||||||
if (!cpu->spu_tname.is_equal(name_cache)) [[unlikely]]
|
if (!cpu->spu_tname.is_equal(name_cache)) [[unlikely]]
|
||||||
{
|
{
|
||||||
name_cache = cpu->spu_tname.load();
|
cpu->spu_tname.peek_op([&](const shared_ptr<std::string>& ptr)
|
||||||
|
{
|
||||||
|
if (ptr != name_cache)
|
||||||
|
{
|
||||||
|
name_cache = ptr;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto type = cpu->get_type();
|
const auto type = cpu->get_type();
|
||||||
|
@ -205,6 +205,11 @@ namespace stx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator element_type*() const noexcept
|
||||||
|
{
|
||||||
|
return m_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
explicit constexpr operator bool() const noexcept
|
explicit constexpr operator bool() const noexcept
|
||||||
{
|
{
|
||||||
return m_ptr != nullptr;
|
return m_ptr != nullptr;
|
||||||
@ -521,6 +526,11 @@ namespace stx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator element_type*() const noexcept
|
||||||
|
{
|
||||||
|
return m_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
explicit constexpr operator bool() const noexcept
|
explicit constexpr operator bool() const noexcept
|
||||||
{
|
{
|
||||||
return m_ptr != nullptr;
|
return m_ptr != nullptr;
|
||||||
@ -731,11 +741,6 @@ namespace stx
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator shared_type() const noexcept
|
|
||||||
{
|
|
||||||
return load();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Atomically inspect pointer with the possibility to reference it if necessary
|
// Atomically inspect pointer with the possibility to reference it if necessary
|
||||||
template <typename F, typename RT = std::invoke_result_t<F, const shared_type&>>
|
template <typename F, typename RT = std::invoke_result_t<F, const shared_type&>>
|
||||||
RT peek_op(F op) const noexcept
|
RT peek_op(F op) const noexcept
|
||||||
|
Loading…
x
Reference in New Issue
Block a user