summaryrefslogtreecommitdiff
path: root/src/core/core.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2022-11-26 13:46:38 -0800
committerGravatar bunnei2022-11-26 13:46:38 -0800
commit8f6245be9a344f53cfca6804bf883a491d113dae (patch)
tree76128f03c99dc1f183edece00a4db083ba1c9810 /src/core/core.cpp
parentMerge pull request #9302 from liamwhite/why-are-we-still-using-ado (diff)
downloadyuzu-8f6245be9a344f53cfca6804bf883a491d113dae.tar.gz
yuzu-8f6245be9a344f53cfca6804bf883a491d113dae.tar.xz
yuzu-8f6245be9a344f53cfca6804bf883a491d113dae.zip
core: Use atomic instead of a lock to protect is_paused.
- This allows us to call IsPaused() elsewhere if we are holding the suspend lock.
Diffstat (limited to 'src/core/core.cpp')
-rw-r--r--src/core/core.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index d8934be52..94d4e2212 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -189,7 +189,7 @@ struct System::Impl {
189 189
190 kernel.Suspend(false); 190 kernel.Suspend(false);
191 core_timing.SyncPause(false); 191 core_timing.SyncPause(false);
192 is_paused = false; 192 is_paused.store(false, std::memory_order_relaxed);
193 193
194 return status; 194 return status;
195 } 195 }
@@ -200,14 +200,13 @@ struct System::Impl {
200 200
201 core_timing.SyncPause(true); 201 core_timing.SyncPause(true);
202 kernel.Suspend(true); 202 kernel.Suspend(true);
203 is_paused = true; 203 is_paused.store(true, std::memory_order_relaxed);
204 204
205 return status; 205 return status;
206 } 206 }
207 207
208 bool IsPaused() const { 208 bool IsPaused() const {
209 std::unique_lock lk(suspend_guard); 209 return is_paused.load(std::memory_order_relaxed);
210 return is_paused;
211 } 210 }
212 211
213 std::unique_lock<std::mutex> StallProcesses() { 212 std::unique_lock<std::mutex> StallProcesses() {
@@ -218,7 +217,7 @@ struct System::Impl {
218 } 217 }
219 218
220 void UnstallProcesses() { 219 void UnstallProcesses() {
221 if (!is_paused) { 220 if (!IsPaused()) {
222 core_timing.SyncPause(false); 221 core_timing.SyncPause(false);
223 kernel.Suspend(false); 222 kernel.Suspend(false);
224 } 223 }
@@ -465,7 +464,7 @@ struct System::Impl {
465 } 464 }
466 465
467 mutable std::mutex suspend_guard; 466 mutable std::mutex suspend_guard;
468 bool is_paused{}; 467 std::atomic_bool is_paused{};
469 std::atomic<bool> is_shutting_down{}; 468 std::atomic<bool> is_shutting_down{};
470 469
471 Timing::CoreTiming core_timing; 470 Timing::CoreTiming core_timing;