Skip to content

Commit b11bedf

Browse files
rasapalaCopilot
andauthored
Update src/shutdown_state.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 87763e2 commit b11bedf

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/shutdown_state.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,27 @@
1515
//*****************************************************************************
1616
#include "shutdown_state.hpp"
1717

18+
#include <atomic>
19+
1820
namespace {
19-
volatile std::sig_atomic_t shutdown_request = 0;
20-
volatile std::sig_atomic_t ovms_exited = 0;
21+
std::atomic<int> shutdown_request{0};
22+
std::atomic<int> ovms_exited{0};
2123
} // namespace
2224

2325
namespace ovms {
2426
int getShutdownRequestValue() {
25-
return shutdown_request;
27+
return shutdown_request.load(std::memory_order_relaxed);
2628
}
2729

2830
void setShutdownRequestValue(int value) {
29-
shutdown_request = value;
31+
shutdown_request.store(value, std::memory_order_relaxed);
3032
}
3133

3234
int getExitStatusValue() {
33-
return ovms_exited;
35+
return ovms_exited.load(std::memory_order_relaxed);
3436
}
3537

3638
void setExitStatusValue(int value) {
37-
ovms_exited = value;
39+
ovms_exited.store(value, std::memory_order_relaxed);
3840
}
3941
} // namespace ovms

0 commit comments

Comments
 (0)