mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-09-29 05:17:33 +00:00
Move atomic implementations
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
|
29
src/atomic/signal.cpp
Normal file
29
src/atomic/signal.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <sta/atomic/signal.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
AtomicSignal::AtomicSignal()
|
||||
: signal_{false}
|
||||
{}
|
||||
|
||||
void AtomicSignal::notify()
|
||||
{
|
||||
signal_.store(true);
|
||||
}
|
||||
|
||||
bool AtomicSignal::peek()
|
||||
{
|
||||
return signal_.load();
|
||||
}
|
||||
|
||||
bool AtomicSignal::test()
|
||||
{
|
||||
return signal_.exchange(false);
|
||||
}
|
||||
|
||||
void AtomicSignal::wait()
|
||||
{
|
||||
while (!signal_.exchange(false));
|
||||
}
|
||||
} // namespace sta
|
Reference in New Issue
Block a user