Add mutex implementation using std::atomic_flag

This commit is contained in:
Henrik Stickann
2022-04-09 21:23:02 +02:00
parent 3abe36ec81
commit d7bd511c70
2 changed files with 44 additions and 0 deletions

19
src/atomic_mutex.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include <sta/atomic_mutex.hpp>
namespace sta
{
AtomicMutex::AtomicMutex()
: lock_{ATOMIC_FLAG_INIT}
{}
void AtomicMutex::acquire()
{
while (lock_.test_and_set());
}
void AtomicMutex::release()
{
lock_.clear();
}
} // namespace sta