DART
6.7.3
|
MultiLockableReference references multiple lockables. More...
#include <LockableReference.hpp>
Public Types | |
using | Lockable = LockableT |
Public Member Functions | |
template<typename InputIterator > | |
MultiLockableReference (std::weak_ptr< const void > lockableHolder, InputIterator first, InputIterator last) | |
Constructs from multiple lockables. More... | |
void | lock () override |
Locks lockable that this class references; blocks if one of the lockables are not avaliable. More... | |
bool | try_lock () noexcept override |
Tries to lock the lockables that this class references; returns false if one of the lockables is not avaliable. More... | |
void | unlock () noexcept override |
Unlocks the lockables. More... | |
Private Member Functions | |
template<typename T > | |
T * | ptr (T &obj) |
Converts reference to pointer. More... | |
template<typename T > | |
T * | ptr (T *obj) |
Returns pointer as it is. More... | |
Private Attributes | |
std::weak_ptr< const void > | mLockableHolder |
Weak pointer to the lockable holder. More... | |
std::vector< Lockable * > | mLockables |
lockables this class references. More... | |
MultiLockableReference references multiple lockables.
MultiLockableReference acquires the locks in the specified order, which means it is the user's responsibility to sort the collection to avoid deadlock.
LockableT | The standard C++ Lockable concept object type. |
using dart::common::MultiLockableReference< LockableT >::Lockable = LockableT |
dart::common::MultiLockableReference< Lockable >::MultiLockableReference | ( | std::weak_ptr< const void > | lockableHolder, |
InputIterator | first, | ||
InputIterator | last | ||
) |
Constructs from multiple lockables.
[in] | lockableHolder | Weak pointer to an object that holds the lockables. This is used to lock/unlock this lockable only when the lockable holder is not destructed. |
[in] | first | First iterator of lockable to be added to this class. |
[in] | last | Last iterator of lockable to be added to this class. |
|
overridevirtual |
Locks lockable that this class references; blocks if one of the lockables are not avaliable.
Implements dart::common::LockableReference.
|
private |
Converts reference to pointer.
|
private |
Returns pointer as it is.
|
overridevirtualnoexcept |
Tries to lock the lockables that this class references; returns false if one of the lockables is not avaliable.
Implements dart::common::LockableReference.
|
overridevirtualnoexcept |
Unlocks the lockables.
Implements dart::common::LockableReference.
|
private |
Weak pointer to the lockable holder.
|
private |
lockables this class references.