mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-02 09:21:54 +00:00
Add mutex interface
This commit is contained in:
commit
2e9f64a045
27
include/sta/mutex.hpp
Normal file
27
include/sta/mutex.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef STA_MUTEX_HPP
|
||||
#define STA_MUTEX_HPP
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Interface for mutex objects.
|
||||
*/
|
||||
class Mutex
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Block until mutex has been acquired
|
||||
*/
|
||||
virtual void acquire() = 0;
|
||||
/**
|
||||
* @brief Release mutex
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
static Mutex * ALWAYS_FREE; /**< Fake mutex that can always be acquired */
|
||||
};
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_MUTEX_HPP
|
20
src/mutex.cpp
Normal file
20
src/mutex.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <sta/mutex.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Dummy mutex implementation with no access control.
|
||||
*/
|
||||
class DummyMutex : public Mutex
|
||||
{
|
||||
public:
|
||||
void acquire() override {}
|
||||
void release() override {}
|
||||
};
|
||||
|
||||
static DummyMutex dummyMutex;
|
||||
|
||||
|
||||
Mutex * Mutex::ALWAYS_FREE = &dummyMutex;
|
||||
} // namespace sta
|
Loading…
x
Reference in New Issue
Block a user