From 5445e974e0cf164c3295d9eaa658b9d62fe42019 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sun, 27 Aug 2023 22:04:04 -0400 Subject: android: Separate emulation states from emulation mutex Emulation states are repeatedly checked by input and performance stats. During startup and shutdown, this could lead to a long halt on the UI thread because the call to IsRunning will be waiting on the emulation mutex to be unlocked. Using atomics should replace the existing functionality without causing problems. --- src/android/app/src/main/jni/native.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 83e88010f..0f2a6d9e4 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -203,12 +203,10 @@ public: } bool IsRunning() const { - std::scoped_lock lock(m_mutex); return m_is_running; } bool IsPaused() const { - std::scoped_lock lock(m_mutex); return m_is_running && m_is_paused; } @@ -544,8 +542,8 @@ private: Core::PerfStatsResults m_perf_stats{}; std::shared_ptr m_vfs; Core::SystemResultStatus m_load_result{Core::SystemResultStatus::ErrorNotInitialized}; - bool m_is_running{}; - bool m_is_paused{}; + std::atomic m_is_running = false; + std::atomic m_is_paused = false; SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; std::unique_ptr m_profile_manager; std::unique_ptr m_manual_provider; -- cgit v1.2.3