mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-14 10:48:36 +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
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "types.h"
|
||||
#include "util/atomic.hpp"
|
||||
#include "util/shared_cptr.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
@ -128,7 +129,7 @@ class thread_base
|
|||
atomic_t<const void*> m_state_notifier{nullptr};
|
||||
|
||||
// Thread name
|
||||
lf_value<std::string> m_name;
|
||||
stx::atomic_cptr<std::string> m_tname;
|
||||
|
||||
//
|
||||
atomic_t<u64> m_cycles = 0;
|
||||
|
@ -186,31 +187,34 @@ class thread_ctrl final
|
|||
|
||||
friend class thread_base;
|
||||
|
||||
// Optimized get_name() for logging
|
||||
static std::string get_name_cached();
|
||||
|
||||
public:
|
||||
// Get current thread name
|
||||
static std::string_view get_name()
|
||||
static std::string get_name()
|
||||
{
|
||||
return g_tls_this_thread->m_name.get();
|
||||
return *g_tls_this_thread->m_tname.load();
|
||||
}
|
||||
|
||||
// Get thread name
|
||||
template <typename T>
|
||||
static std::string_view get_name(const named_thread<T>& thread)
|
||||
static std::string get_name(const named_thread<T>& thread)
|
||||
{
|
||||
return static_cast<const thread_base&>(thread).m_name.get();
|
||||
return *static_cast<const thread_base&>(thread).m_tname.load();
|
||||
}
|
||||
|
||||
// Set current thread name (not recommended)
|
||||
static void set_name(std::string_view name)
|
||||
{
|
||||
g_tls_this_thread->m_name.assign(name);
|
||||
g_tls_this_thread->m_tname.store(stx::shared_cptr<std::string>::make(name));
|
||||
}
|
||||
|
||||
// Set thread name (not recommended)
|
||||
template <typename T>
|
||||
static void set_name(named_thread<T>& thread, std::string_view name)
|
||||
{
|
||||
static_cast<thread_base&>(thread).m_name.assign(name);
|
||||
static_cast<thread_base&>(thread).m_tname.store(stx::shared_cptr<std::string>::make(name));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue