From c9c8537643b970c44d60961f3fefaa223a4a2362 Mon Sep 17 00:00:00 2001 From: Rodrigo Locatti Date: Tue, 22 Jun 2021 04:22:19 -0300 Subject: core: Make is_powered_on atomic Fixes potential data races when shutting down. --- src/core/core.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/core.cpp b/src/core/core.cpp index c5004b7b4..e6f1aa0e7 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include @@ -377,7 +378,7 @@ struct System::Impl { std::unique_ptr device_memory; Core::Memory::Memory memory; CpuManager cpu_manager; - bool is_powered_on = false; + std::atomic_bool is_powered_on{}; bool exit_lock = false; Reporter reporter; @@ -463,7 +464,7 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st } bool System::IsPoweredOn() const { - return impl->is_powered_on; + return impl->is_powered_on.load(std::memory_order::relaxed); } void System::PrepareReschedule() { -- cgit v1.2.3