DART  6.10.1
dart::common::SingleLockableReference< LockableT > Class Template Referencefinal

This class references a single lockable. More...

#include <LockableReference.hpp>

Inheritance diagram for dart::common::SingleLockableReference< LockableT >:
dart::common::LockableReference

Public Types

using Lockable = LockableT
 

Public Member Functions

 SingleLockableReference (std::weak_ptr< const void > lockableHolder, Lockable &lockable) noexcept
 Constructor from a single lockable. 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 Attributes

std::weak_ptr< const void > mLockableHolder
 Weak pointer to the lockable holder. More...
 
LockablemLockable
 Lockable this class references. More...
 

Detailed Description

template<typename LockableT>
class dart::common::SingleLockableReference< LockableT >

This class references a single lockable.

Template Parameters
LockableTThe standard C++ Lockable concept object type.

Member Typedef Documentation

◆ Lockable

template<typename LockableT >
using dart::common::SingleLockableReference< LockableT >::Lockable = LockableT

Constructor & Destructor Documentation

◆ SingleLockableReference()

template<typename Lockable >
dart::common::SingleLockableReference< Lockable >::SingleLockableReference ( std::weak_ptr< const void >  lockableHolder,
Lockable lockable 
)
noexcept

Constructor from a single lockable.

Parameters
[in]lockableHolderWeak pointer to an object that holds the lockable. This is used to check whether the lockable holder is not destructed before lock/unlock.
[in]lockable

Member Function Documentation

◆ lock()

template<typename Lockable >
void dart::common::SingleLockableReference< Lockable >::lock ( )
overridevirtual

Locks lockable that this class references; blocks if one of the lockables are not avaliable.

Implements dart::common::LockableReference.

◆ try_lock()

template<typename Lockable >
bool dart::common::SingleLockableReference< Lockable >::try_lock ( )
overridevirtualnoexcept

Tries to lock the lockables that this class references; returns false if one of the lockables is not avaliable.

Implements dart::common::LockableReference.

◆ unlock()

template<typename Lockable >
void dart::common::SingleLockableReference< Lockable >::unlock ( )
overridevirtualnoexcept

Unlocks the lockables.

Implements dart::common::LockableReference.

Member Data Documentation

◆ mLockable

template<typename LockableT >
Lockable& dart::common::SingleLockableReference< LockableT >::mLockable
private

Lockable this class references.

◆ mLockableHolder

template<typename LockableT >
std::weak_ptr<const void> dart::common::SingleLockableReference< LockableT >::mLockableHolder
private

Weak pointer to the lockable holder.