mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-09-28 21:17:33 +00:00
Add mutex implementation using std::atomic_flag
This commit is contained in:
19
src/atomic_mutex.cpp
Normal file
19
src/atomic_mutex.cpp
Normal 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
|
Reference in New Issue
Block a user