mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-13 01:55:59 +00:00
39 lines
629 B
C++
39 lines
629 B
C++
/**
|
|
* @brief Atomic mutex implementation.
|
|
*
|
|
* Define **STA_ATOMIC_ENABLE** to enable module.
|
|
*/
|
|
#ifndef STA_ATOMIC_MUTEX_HPP
|
|
#define STA_ATOMIC_MUTEX_HPP
|
|
|
|
#include <sta/config.hpp>
|
|
#ifdef STA_ATOMIC_ENABLE
|
|
|
|
#include <sta/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
|