A container for data that is protected by a mutex. Inspired by Mutex in Rust.
More...
#include <Mutex.hpp>
|
| | Mutex (ProtectedDataType data) |
| | Construct a new Mutex object with the given data.
|
| template<template< typename... > typename LockType = std::lock_guard> |
| Lock< ProtectedDataType const, LockType, MutexType > | lock () const |
| | Lock the mutex and get a lock object allowing access to the protected data.
|
| template<template< typename... > typename LockType = std::lock_guard> |
| Lock< ProtectedDataType, LockType, MutexType > | lock () |
| | Lock the mutex and get a lock object allowing access to the protected data.
|
|
| template<typename... Args> |
| static Mutex | make (Args &&... args) |
| | Make a new Mutex object with the given data.
|
template<typename ProtectedDataType, typename MutexType = std::mutex>
class util::Mutex< ProtectedDataType, MutexType >
A container for data that is protected by a mutex. Inspired by Mutex in Rust.
- Template Parameters
-
| ProtectedDataType | data type to hold |
| MutexType | type of mutex |
◆ Mutex()
template<typename ProtectedDataType, typename MutexType = std::mutex>
| util::Mutex< ProtectedDataType, MutexType >::Mutex |
( |
ProtectedDataType | data | ) |
|
|
inlineexplicit |
Construct a new Mutex object with the given data.
- Parameters
-
◆ lock() [1/2]
template<typename ProtectedDataType, typename MutexType = std::mutex>
template<template< typename... > typename LockType = std::lock_guard>
| Lock< ProtectedDataType, LockType, MutexType > util::Mutex< ProtectedDataType, MutexType >::lock |
( |
| ) |
|
|
inline |
Lock the mutex and get a lock object allowing access to the protected data.
- Template Parameters
-
| LockType | The type of lock to use |
- Returns
- A lock on the mutex and a reference to the protected data
◆ lock() [2/2]
template<typename ProtectedDataType, typename MutexType = std::mutex>
template<template< typename... > typename LockType = std::lock_guard>
| Lock< ProtectedDataType const, LockType, MutexType > util::Mutex< ProtectedDataType, MutexType >::lock |
( |
| ) |
const |
|
inline |
Lock the mutex and get a lock object allowing access to the protected data.
- Template Parameters
-
| LockType | The type of lock to use |
- Returns
- A lock on the mutex and a reference to the protected data
◆ make()
template<typename ProtectedDataType, typename MutexType = std::mutex>
template<typename... Args>
| Mutex util::Mutex< ProtectedDataType, MutexType >::make |
( |
Args &&... | args | ) |
|
|
inlinestatic |
Make a new Mutex object with the given data.
- Template Parameters
-
| Args | The types of the arguments to forward to the constructor of the protected data |
- Parameters
-
| args | The arguments to forward to the constructor of the protected data |
- Returns
- The Mutex object that protects the given data
The documentation for this class was generated from the following file: