/** * @file * @brief Atomic mutex implementation. * * Configuration: * STA_STDLIB_HAS_ATOMIC: Enable module */ #ifndef STA_CORE_ATOMIC_MUTEX_HPP #define STA_CORE_ATOMIC_MUTEX_HPP #include #ifdef STA_STDLIB_HAS_ATOMIC # define STA_ATOMIC_ENABLED #endif // STA_STDLIB_HAS_ATOMIC #if defined(STA_ATOMIC_ENABLED) || defined(DOXYGEN) #include #include namespace sta { /** * @brief Implementation of `Mutex` interface using `std::atomic_flag`. */ class AtomicMutex : public Mutex { public: AtomicMutex(); void acquire() override; void release() override; private: std::atomic_flag lock_; /**< Atomic flag used as lock */ }; } // namespace sta #endif // STA_ATOMIC_ENABLED #endif // STA_CORE_ATOMIC_MUTEX_HPP