sta-core/include/sta/atomic/signal.hpp
2022-05-02 13:37:44 +02:00

42 lines
696 B
C++

/**
* @brief Atomic signal implementation.
*
* Configuration:
* STA_ATOMIC_ENABLE: Enable module
*/
#ifndef STA_ATOMIC_SIGNAL_HPP
#define STA_ATOMIC_SIGNAL_HPP
#include <sta/config.hpp>
#ifdef STA_ATOMIC_ENABLE
#include <sta/intf/signal.hpp>
#include <atomic>
namespace sta
{
/**
* @brief Implementation of `Signal` interface using `std::atomic`.
*/
class AtomicSignal : public Signal
{
public:
AtomicSignal();
void notify() override;
bool peek() override;
bool test() override;
void wait() override;
private:
std::atomic<bool> signal_; /**< Atomic bool used as signal */
};
} // namespace sta
#endif // STA_ATOMIC_ENABLE
#endif // STA_ATOMIC_SIGNAL_HPP