A simple atomic wrapper.
More...
#include <Atomic.h>
|
|
using | value_type = Type |
| | Alias for the type.
|
| |
|
using | WriteLockType = std::lock_guard< MutexType > |
| | Alias for the atomic write mutex lock.
|
| |
|
| template<class SomeType > |
| | Atomic (SomeType &&am) |
| | Creates the Atomic instance. More...
|
| |
|
| Atomic () |
| | Creates the Atomic instance.
|
| |
| template<class Functor > |
| auto | locked (Functor &&lambda) -> decltype(lambda(std::declval< Type & >())) |
| | Calls the lambda function using the unique lock. More...
|
| |
| template<class Functor > |
| auto | locked (Functor &&lambda) const -> decltype(lambda(std::declval< const Type & >())) const |
| | Calls the lambda using the lock. More...
|
| |
| Type | lockedCopy () const |
| | Gets a copy of the data using the lock. More...
|
| |
| Type | lockedMove () |
| | Gets a copy of the moved data using the unique lock. More...
|
| |
| template<class SomeType > |
| void | lockedAssign (SomeType &&am) |
| | Assigns the data using the unique lock. More...
|
| |
| void | lockedSwap (Type &other) |
| | Exchanges context with the Type object using the unique lock. More...
|
| |
| Type | lockedSwapWithDefault () |
| | Exchanges context with the Type object using the unique lock and moves data. More...
|
| |
| | operator bool () const |
| | Converts to bool if the wrapped type is bool convertible. More...
|
| |
|
|
MutexType | m_mutex |
| | Defines the lock type.
|
| |
|
Type | m |
| | The member type to which atomic access is required.
|
| |
template<class Type, typename MutexType = std::mutex, typename ReadLockType = std::lock_guard<MutexType>>
class olp::thread::Atomic< Type, MutexType, ReadLockType >
A simple atomic wrapper.
Depending on the provided MutexType, it can be multi-read/single-write or single-read/single-write.
- Template Parameters
-
| Type | The member type to which atomic access is required. |
| MutexType | Defines the lock type. |
| ReadLockType | Defines the locking strategy for the atomic read operation. |
◆ Atomic()
template<class Type , typename MutexType = std::mutex, typename ReadLockType = std::lock_guard<MutexType>>
template<class SomeType >
Creates the Atomic instance.
- Template Parameters
-
| SomeType | The variable type that is used for initialization. |
- Parameters
-
| am | The rvalue reference of the SomeType instance. |
◆ locked() [1/2]
template<class Type , typename MutexType = std::mutex, typename ReadLockType = std::lock_guard<MutexType>>
template<class Functor >
| auto olp::thread::Atomic< Type, MutexType, ReadLockType >::locked |
( |
Functor && |
lambda | ) |
-> decltype(lambda(std::declval<Type&>())) |
|
inline |
Calls the lambda function using the unique lock.
- Template Parameters
-
| Functor | Accepts the single parameter of Type&. |
- Parameters
-
| lambda | The function of the Functor type. |
- Returns
- The lambda result.
◆ locked() [2/2]
template<class Type , typename MutexType = std::mutex, typename ReadLockType = std::lock_guard<MutexType>>
template<class Functor >
| auto olp::thread::Atomic< Type, MutexType, ReadLockType >::locked |
( |
Functor && |
lambda | ) |
const -> decltype(lambda(std::declval<const Type&>())) const |
|
inline |
Calls the lambda using the lock.
Used for the const version of this class.
- Template Parameters
-
| Functor | Accepts the single parameter of const Type&. |
- Parameters
-
| lambda | The function of the Functor type. |
- Returns
- The lambda result.
◆ lockedAssign()
template<class Type , typename MutexType = std::mutex, typename ReadLockType = std::lock_guard<MutexType>>
template<class SomeType >
Assigns the data using the unique lock.
- Template Parameters
-
| SomeType | The variable type that is used for initialization. |
- Parameters
-
| am | The rvalue reference of the SomeType instance. |
◆ lockedCopy()
template<class Type , typename MutexType = std::mutex, typename ReadLockType = std::lock_guard<MutexType>>
Gets a copy of the data using the lock.
- Returns
- The copy of the data.
◆ lockedMove()
template<class Type , typename MutexType = std::mutex, typename ReadLockType = std::lock_guard<MutexType>>
Gets a copy of the moved data using the unique lock.
- Returns
- The copy of the moved data.
◆ lockedSwap()
template<class Type , typename MutexType = std::mutex, typename ReadLockType = std::lock_guard<MutexType>>
Exchanges context with the Type object using the unique lock.
- Parameters
-
| other | The copy of the value specified in the Type object. |
◆ lockedSwapWithDefault()
template<class Type , typename MutexType = std::mutex, typename ReadLockType = std::lock_guard<MutexType>>
Exchanges context with the Type object using the unique lock and moves data.
- Returns
- The copy of the value specified in the
Type object.
◆ operator bool()
template<class Type , typename MutexType = std::mutex, typename ReadLockType = std::lock_guard<MutexType>>
Converts to bool if the wrapped type is bool convertible.
- Returns
- True if the wrapped type is bool convertible; false otherwise.
The documentation for this class was generated from the following file:
- olp-cpp-sdk-core/include/olp/core/thread/Atomic.h