2022-05-02 13:37:44 +02:00

40 lines
642 B
C++

/**
* @brief Atomic mutex implementation.
*
* Configuration:
* STA_ATOMIC_ENABLE: Enable module
*/
#ifndef STA_ATOMIC_MUTEX_HPP
#define STA_ATOMIC_MUTEX_HPP
#include <sta/config.hpp>
#ifdef STA_ATOMIC_ENABLE
#include <sta/intf/mutex.hpp>
#include <atomic>
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_ENABLE
#endif // STA_ATOMIC_MUTEX_HPP