MIRA
|
Grants thread-safe access to an object (the Protectee) that should be protected from concurrent access. More...
#include <thread/ScopedAccess.h>
Public Member Functions | |
ScopedAccess (Protectee *p, Mutex *m, bool lockedAlready=false) | |
This is used to create an access object to a protected object, which is passed as pointer. More... | |
~ScopedAccess () | |
ScopedAccess (ScopedAccess &&other) noexcept | |
ScopedAccess & | operator= (ScopedAccess &&other) noexcept |
Protectee * | operator-> () |
const Protectee * | operator-> () const |
Protectee & | operator* () |
const Protectee & | operator* () const |
Protected Attributes | |
Mutex * | mMutex |
Protectee * | mObject |
Grants thread-safe access to an object (the Protectee) that should be protected from concurrent access.
The protectee or its owner can return a ScopedAccess object to the user. The ScopedAccess object contains a reference to the protectee and will delegate all calls to it. Moreover, the ScopedAccess will automatically take care of locking and unlocking, i.e. it will keep the mutex locked over its entire lifetime and release the lock when it goes out of scope.
A not specified Mutex type (default=void), will select the specialization for Mutex=void, where the Protectee itself is expected to provide lock/unlock.
|
inline |
This is used to create an access object to a protected object, which is passed as pointer.
The third parameter specifies if the object is already locked. If not (the default), it is locked immediately. Note that in both cases the object will be unlocked in ScopedAccess's destructor and should NOT be unlocked outside to prevent double unlock!
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
protected |
|
protectedinherited |