Files
BloomPatched/src/Helpers/ConditionVariableNotifier.hpp
Nav 6cdbfbe950 Massive refactor to accommodate RISC-V targets
- Refactored entire codebase (excluding the Insight component) to accommodate multiple target architectures (no longer specific to AVR)
- Deleted 'generate SVD' GDB monitor command - I will eventually move this functionality to the Bloom website
- Added unit size property to address spaces
- Many other changes which I couldn't be bothered to describe here
2024-07-23 21:14:22 +01:00

38 lines
1.1 KiB
C++

#pragma once
#include <mutex>
#include <condition_variable>
#include <chrono>
#include <optional>
#include "NotifierInterface.hpp"
/**
* The ConditionVariableNotifier class is an implementation of the NotifierInterface, using an
* std::condition_variable.
*/
class ConditionVariableNotifier: public NotifierInterface
{
public:
ConditionVariableNotifier() = default;
~ConditionVariableNotifier() override = default;
ConditionVariableNotifier(ConditionVariableNotifier& other) = delete;
ConditionVariableNotifier& operator = (ConditionVariableNotifier& other) = delete;
ConditionVariableNotifier(ConditionVariableNotifier&& other) noexcept = delete;
ConditionVariableNotifier& operator = (ConditionVariableNotifier&& other) = delete;
void notify() override;
/**
* Blocks until the contained std::conditional_variable is notified.
*/
void waitForNotification(std::optional<std::chrono::milliseconds> timeout = std::nullopt);
private:
std::mutex mutex;
std::condition_variable conditionalVariable;
bool notified = false;
};