mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 00:36:00 +00:00
RAII-style mutex
This commit is contained in:
parent
e186eb757c
commit
e5c4b9a6cc
@ -5,9 +5,16 @@
|
||||
#ifndef STA_CORE_MUTEX_HPP
|
||||
#define STA_CORE_MUTEX_HPP
|
||||
|
||||
#include <mutex>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Hippity hoppity, this is now namespace sta's property.
|
||||
*/
|
||||
using std::lock_guard;
|
||||
|
||||
/**
|
||||
* @brief Interface for mutex objects.
|
||||
*
|
||||
@ -25,6 +32,16 @@ namespace sta
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
* @brief Identical to acquire(). Added for compatibility with std::lock_guard.
|
||||
*/
|
||||
void lock();
|
||||
|
||||
/**
|
||||
* @brief Identical to release(). Added for compatibility with std::lock_guard.
|
||||
*/
|
||||
void unlock();
|
||||
|
||||
static Mutex * ALWAYS_FREE; /**< Fake mutex that can always be acquired */
|
||||
};
|
||||
} // namespace sta
|
||||
|
@ -3,6 +3,16 @@
|
||||
|
||||
namespace sta
|
||||
{
|
||||
void Mutex::lock()
|
||||
{
|
||||
acquire();
|
||||
}
|
||||
|
||||
void Mutex::unlock()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dummy mutex implementation with no access control.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user