CPU: Convert static variable to class member

Make s_have_fake_cpu_thread a class member instead. In addition to
getting rid of a bit of static state, this simplifies refactoring in an
upcoming commit.
This commit is contained in:
Dentomologist 2023-06-02 16:15:41 -07:00
parent c22a483431
commit bebeba29c3
2 changed files with 5 additions and 5 deletions

View File

@ -353,8 +353,6 @@ void CPUManager::Continue()
bool CPUManager::PauseAndLock(bool do_lock, bool unpause_on_unlock, bool control_adjacent) bool CPUManager::PauseAndLock(bool do_lock, bool unpause_on_unlock, bool control_adjacent)
{ {
// NOTE: This is protected by m_stepping_lock.
static bool s_have_fake_cpu_thread = false;
bool was_unpaused = false; bool was_unpaused = false;
if (do_lock) if (do_lock)
@ -380,16 +378,16 @@ bool CPUManager::PauseAndLock(bool do_lock, bool unpause_on_unlock, bool control
// depth counter instead of being a boolean. // depth counter instead of being a boolean.
if (!Core::IsCPUThread()) if (!Core::IsCPUThread())
{ {
s_have_fake_cpu_thread = true; m_have_fake_cpu_thread = true;
Core::DeclareAsCPUThread(); Core::DeclareAsCPUThread();
} }
} }
else else
{ {
// Only need the stepping lock for this // Only need the stepping lock for this
if (s_have_fake_cpu_thread) if (m_have_fake_cpu_thread)
{ {
s_have_fake_cpu_thread = false; m_have_fake_cpu_thread = false;
Core::UndeclareAsCPUThread(); Core::UndeclareAsCPUThread();
} }

View File

@ -122,6 +122,8 @@ private:
// deadlock because of the order inversion. (A -> X,Y; B -> Y,X; A waits for // deadlock because of the order inversion. (A -> X,Y; B -> Y,X; A waits for
// B, B waits for A) // B, B waits for A)
std::mutex m_stepping_lock; std::mutex m_stepping_lock;
// Protected by m_stepping_lock.
bool m_have_fake_cpu_thread = false;
// Primary lock. Protects changing m_state, requesting instruction stepping and // Primary lock. Protects changing m_state, requesting instruction stepping and
// pause-and-locking. // pause-and-locking.