sta-core/src/atomic/mutex.cpp
2023-02-02 22:22:14 +01:00

24 lines
349 B
C++

#include <sta/atomic/mutex.hpp>
#ifdef STA_ATOMIC_ENABLED
namespace sta
{
AtomicMutex::AtomicMutex()
: lock_{ATOMIC_FLAG_INIT}
{}
void AtomicMutex::acquire()
{
while (lock_.test_and_set());
}
void AtomicMutex::release()
{
lock_.clear();
}
} // namespace sta
#endif // STA_ATOMIC_ENABLED