mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12:00
Remove cancerous lf_value<>
Replace thread names (generic, PPU, SPU) with new shared pointers. Devirtualize cpu_thread::get_name (used in single case).
This commit is contained in:
parent
bf4bdf73b7
commit
65eeee0f4c
11 changed files with 99 additions and 122 deletions
|
@ -1742,9 +1742,11 @@ void thread_base::initialize(bool(*wait_cb)(const void*))
|
|||
|
||||
g_tls_log_prefix = []
|
||||
{
|
||||
return thread_ctrl::g_tls_this_thread->m_name.get();
|
||||
return thread_ctrl::get_name_cached();
|
||||
};
|
||||
|
||||
std::string name = thread_ctrl::get_name_cached();
|
||||
|
||||
#ifdef _MSC_VER
|
||||
struct THREADNAME_INFO
|
||||
{
|
||||
|
@ -1755,11 +1757,11 @@ void thread_base::initialize(bool(*wait_cb)(const void*))
|
|||
};
|
||||
|
||||
// Set thread name for VS debugger
|
||||
if (IsDebuggerPresent())
|
||||
if (IsDebuggerPresent()) [&]() NEVER_INLINE
|
||||
{
|
||||
THREADNAME_INFO info;
|
||||
info.dwType = 0x1000;
|
||||
info.szName = m_name.get().c_str();
|
||||
info.szName = name.c_str();
|
||||
info.dwThreadID = -1;
|
||||
info.dwFlags = 0;
|
||||
|
||||
|
@ -1770,17 +1772,19 @@ void thread_base::initialize(bool(*wait_cb)(const void*))
|
|||
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
}
|
||||
}
|
||||
}();
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
pthread_setname_np(m_name.get().substr(0, 15).c_str());
|
||||
name.resize(std::min<std::size_t>(15, name.size()));
|
||||
pthread_setname_np(name.c_str());
|
||||
#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
pthread_set_name_np(pthread_self(), m_name.get().c_str());
|
||||
pthread_set_name_np(pthread_self(), name.c_str());
|
||||
#elif defined(__NetBSD__)
|
||||
pthread_setname_np(pthread_self(), "%s", const_cast<char*>(m_name.get().c_str()));
|
||||
pthread_setname_np(pthread_self(), "%s", name.data());
|
||||
#elif !defined(_WIN32)
|
||||
pthread_setname_np(pthread_self(), m_name.get().substr(0, 15).c_str());
|
||||
name.resize(std::min<std::size_t>(15, name.size()));
|
||||
pthread_setname_np(pthread_self(), name.c_str());
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
|
@ -1842,7 +1846,7 @@ bool thread_base::finalize(int) noexcept
|
|||
|
||||
g_tls_log_prefix = []
|
||||
{
|
||||
return thread_ctrl::g_tls_this_thread->m_name.get();
|
||||
return thread_ctrl::get_name_cached();
|
||||
};
|
||||
|
||||
sig_log.notice("Thread time: %fs (%fGc); Faults: %u [rsx:%u, spu:%u]; [soft:%u hard:%u]; Switches:[vol:%u unvol:%u]",
|
||||
|
@ -1934,8 +1938,27 @@ void thread_ctrl::_wait_for(u64 usec, bool alert /* true */)
|
|||
}
|
||||
}
|
||||
|
||||
std::string thread_ctrl::get_name_cached()
|
||||
{
|
||||
auto _this = thread_ctrl::g_tls_this_thread;
|
||||
|
||||
if (!_this)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
static thread_local stx::shared_cptr<std::string> name_cache;
|
||||
|
||||
if (!_this->m_tname.is_equal(name_cache)) [[unlikely]]
|
||||
{
|
||||
name_cache = _this->m_tname.load();
|
||||
}
|
||||
|
||||
return *name_cache;
|
||||
}
|
||||
|
||||
thread_base::thread_base(std::string_view name)
|
||||
: m_name(name)
|
||||
: m_tname(stx::shared_cptr<std::string>::make(name))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue