1
0
Fork 0
forked from suyu/suyu
suyu/src/core/arm/cpu_interrupt_handler.h
ReinUsesLisp ea7bda25ba cpu_interrupt_handler: Make is_interrupted an atomic
Fixes a race condition detected from tsan
2020-08-26 02:43:15 +00:00

40 lines
859 B
C++

// Copyright 2020 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <atomic>
#include <memory>
namespace Common {
class Event;
}
namespace Core {
class CPUInterruptHandler {
public:
CPUInterruptHandler();
~CPUInterruptHandler();
CPUInterruptHandler(const CPUInterruptHandler&) = delete;
CPUInterruptHandler& operator=(const CPUInterruptHandler&) = delete;
CPUInterruptHandler(CPUInterruptHandler&&) = default;
CPUInterruptHandler& operator=(CPUInterruptHandler&&) = default;
bool IsInterrupted() const {
return is_interrupted;
}
void SetInterrupt(bool is_interrupted);
void AwaitInterrupt();
private:
std::atomic_bool is_interrupted{false};
std::unique_ptr<Common::Event> interrupt_event;
};
} // namespace Core