mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 16:55:58 +00:00
49 lines
900 B
C++
49 lines
900 B
C++
/**
|
|
* @file
|
|
* @brief Atomic signal implementation.
|
|
*
|
|
* Configuration:
|
|
* STA_STDLIB_HAS_ATOMIC: Enable module
|
|
*/
|
|
#ifndef STA_CORE_ATOMIC_SIGNAL_HPP
|
|
#define STA_CORE_ATOMIC_SIGNAL_HPP
|
|
|
|
|
|
#include <sta/config.hpp>
|
|
#ifdef STA_STDLIB_HAS_ATOMIC
|
|
# define STA_ATOMIC_ENABLED
|
|
#endif // STA_STDLIB_HAS_ATOMIC
|
|
|
|
|
|
#if defined(STA_ATOMIC_ENABLED) || defined(DOXYGEN)
|
|
|
|
#include <sta/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_ENABLED
|
|
|
|
#endif // STA_CORE_ATOMIC_SIGNAL_HPP
|