|
CeresEngine 0.2.0
A game development framework
|
A helper class that wraps and protects a value from non-synchronized access. More...
#include <CeresEngine/Foundation/Threading/Threading.hpp>
Classes | |
| class | TemporaryLock |
A helper class that acquires a temporary lock and overloads operator-> to allow access to the object. More... | |
Public Types | |
| using | ValueType = T |
The type of value used by the LockedObject instance. | |
| using | MutexType = Mutex |
The type of mutex used by the LockedObject instance. | |
Public Member Functions | |
| template<typename... Args> | |
| LockedObject (Args &&... args) | |
Creates a new LockedObject instance by constructing a new object of type T by forwarding Args to the constructor. | |
| template<typename OtherMutex > | |
| LockedObject (const LockedObject< T, OtherMutex > &other) | |
Creates a new LockedObject by copying the value of another. | |
| template<typename OtherMutex > | |
| LockedObject & | operator= (const LockedObject< T, OtherMutex > &other) |
Assigns the LockedObject by copying the value of another. | |
| LockedObject & | operator= (const T &other) |
Assigns the LockedObject by copying a value. | |
| template<typename OtherMutex > | |
| LockedObject & | operator= (LockedObject< T, OtherMutex > &&other) noexcept |
Assigns the LockedObject by moving the value of another. | |
| LockedObject & | operator= (T &&other) noexcept |
Assigns the LockedObject by copying a value. | |
| template<typename Func > | |
| decltype(auto) | with (Func &&func) |
Executes a function Func within a synchronized block. | |
| template<typename Func > | |
| decltype(auto) | operator| (Func &&func) |
Executes a function Func within a synchronized block. | |
| template<typename Func > | |
| decltype(auto) | operator() (Func &&func) |
Executes a function Func within a synchronized block. | |
| auto | lock () |
Access the LockedObject contents by acquiring a temporary lock. | |
| auto | operator-> () |
Executes a function Func within a synchronized block by locking all objects. | |
| auto | operator* () |
Executes a function Func within a synchronized block by locking all objects. | |
| template<typename Func > | |
| decltype(auto) | with (Func &&func) const |
Executes a function Func within a synchronized block. | |
| template<typename Func > | |
| decltype(auto) | operator| (Func &&func) const |
Executes a function Func within a synchronized block. | |
| template<typename Func > | |
| decltype(auto) | operator() (Func &&func) const |
Executes a function Func within a synchronized block. | |
| auto | lock () const |
Access the LockedObject contents by acquiring a temporary lock. | |
| auto | operator-> () const |
Executes a function Func within a synchronized block by locking all objects. | |
| auto | operator* () const |
Executes a function Func within a synchronized block by locking all objects. | |
| T | copy () const |
| Returns a copy of the locked object. | |
Private Attributes | |
| T | mValue |
| The value that is locked and guarded by the mutex. | |
| Mutex | mMutex |
| The mutex guarding the value. | |
Friends | |
| template<typename , typename > | |
| class | LockedObject |
| template<CLockedObject... Ts, typename Func > | |
| decltype(auto) | lock (Func &&func, Ts &... objects) |
Executes a function Func within a synchronized block by locking all objects. | |
A helper class that wraps and protects a value from non-synchronized access.
Access to the underlying stored value must be done via with or copy methods.
| T | The object type that is guarded by the object. |
| Mutex | The type of mutex to be used by the guard. |
| using CeresEngine::LockedObject< T, Mutex >::MutexType = Mutex |
The type of mutex used by the LockedObject instance.
| using CeresEngine::LockedObject< T, Mutex >::ValueType = T |
The type of value used by the LockedObject instance.
|
inline |
Creates a new LockedObject instance by constructing a new object of type T by forwarding Args to the constructor.
| Args | The constructor argument types. |
| args | The argument arguments. |
|
inline |
Creates a new LockedObject by copying the value of another.
| other | The LockedObject to copy from. |
|
inline |
Returns a copy of the locked object.
The copy is done safely with the mutex locked.
|
inline |
Access the LockedObject contents by acquiring a temporary lock.
|
inline |
Access the LockedObject contents by acquiring a temporary lock.
|
inline |
Executes a function Func within a synchronized block.
| Func | The function to be called with the synchronized object. |
| func | The function to be called with the synchronized object. |
func, if any.
|
inline |
Executes a function Func within a synchronized block.
This is similar to the non-const variant but acquires a shared lock and only calls func with a const value.
| Func | The function to be called with the synchronized object. |
| func | The function to be called with the synchronized object. |
func, if any.
|
inline |
Executes a function Func within a synchronized block by locking all objects.
| objects | The objects to be synchronized. |
| func | The function to be called with the synchronized objects. |
func, if any.
|
inline |
Executes a function Func within a synchronized block by locking all objects.
| objects | The objects to be synchronized. |
| func | The function to be called with the synchronized objects. |
func, if any.
|
inline |
Executes a function Func within a synchronized block by locking all objects.
| objects | The objects to be synchronized. |
| func | The function to be called with the synchronized objects. |
func, if any.
|
inline |
Executes a function Func within a synchronized block by locking all objects.
| objects | The objects to be synchronized. |
| func | The function to be called with the synchronized objects. |
func, if any.
|
inline |
Assigns the LockedObject by copying the value of another.
| other | The LockedObject to copy from. |
|
inline |
Assigns the LockedObject by copying a value.
| other | The valued to be copy assigned. |
|
inlinenoexcept |
Assigns the LockedObject by moving the value of another.
| other | The LockedObject to move from. |
|
inlinenoexcept |
Assigns the LockedObject by copying a value.
| other | The valued to be copy assigned. |
|
inline |
Executes a function Func within a synchronized block.
| Func | The function to be called with the synchronized object. |
| func | The function to be called with the synchronized object. |
func, if any.
|
inline |
Executes a function Func within a synchronized block.
This is similar to the non-const variant but acquires a shared lock and only calls func with a const value.
| Func | The function to be called with the synchronized object. |
| func | The function to be called with the synchronized object. |
func, if any. Executes a function Func within a synchronized block.
| Func | The function to be called with the synchronized object. |
| func | The function to be called with the synchronized object. |
func, if any. Executes a function Func within a synchronized block.
This is similar to the non-const variant but acquires a shared lock and only calls func with a const value.
| Func | The function to be called with the synchronized object. |
| func | The function to be called with the synchronized object. |
func, if any. Executes a function Func within a synchronized block by locking all objects.
| objects | The objects to be synchronized. |
| func | The function to be called with the synchronized objects. |
func, if any.
|
friend |
|
mutableprivate |
The mutex guarding the value.
|
private |
The value that is locked and guarded by the mutex.