mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-12 01:25:59 +00:00
42 lines
696 B
C++
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
|