Просмотр исходного кода

cpu_interrupt_handler: Make is_interrupted an atomic

Fixes a race condition detected from tsan
ReinUsesLisp 5 лет назад
Родитель
Сommit
ea7bda25ba
2 измененных файлов с 3 добавлено и 2 удалено
  1. 1 1
      src/core/arm/cpu_interrupt_handler.cpp
  2. 2 1
      src/core/arm/cpu_interrupt_handler.h

+ 1 - 1
src/core/arm/cpu_interrupt_handler.cpp

@@ -7,7 +7,7 @@
 
 
 namespace Core {
 namespace Core {
 
 
-CPUInterruptHandler::CPUInterruptHandler() : is_interrupted{} {
+CPUInterruptHandler::CPUInterruptHandler() {
     interrupt_event = std::make_unique<Common::Event>();
     interrupt_event = std::make_unique<Common::Event>();
 }
 }
 
 

+ 2 - 1
src/core/arm/cpu_interrupt_handler.h

@@ -4,6 +4,7 @@
 
 
 #pragma once
 #pragma once
 
 
+#include <atomic>
 #include <memory>
 #include <memory>
 
 
 namespace Common {
 namespace Common {
@@ -32,7 +33,7 @@ public:
     void AwaitInterrupt();
     void AwaitInterrupt();
 
 
 private:
 private:
-    bool is_interrupted{};
+    std::atomic_bool is_interrupted{false};
     std::unique_ptr<Common::Event> interrupt_event;
     std::unique_ptr<Common::Event> interrupt_event;
 };
 };