dart
Public Types | Public Member Functions | List of all members
dart::common::MultiLockableReference< LockableT > Class Template Referencefinal

MultiLockableReference references multiple lockables. More...

#include <LockableReference.hpp>

Inheritance diagram for dart::common::MultiLockableReference< LockableT >:
Inheritance graph
[legend]
Collaboration diagram for dart::common::MultiLockableReference< LockableT >:
Collaboration graph
[legend]

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.
 
- Public Member Functions inherited from dart::common::LockableReference
constexpr LockableReference () noexcept=default
 Default construtor.
 
virtual ~LockableReference ()=default
 Default destructor.
 

Additional Inherited Members

- Protected Member Functions inherited from dart::common::LockableReference
 LockableReference (const LockableReference &)=delete
 Copy construction is not allowed.
 

Detailed Description

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

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.

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

Constructor & Destructor Documentation

◆ MultiLockableReference()

template<typename Lockable >
template<typename InputIterator >
dart::common::MultiLockableReference< Lockable >::MultiLockableReference ( std::weak_ptr< const void >  lockableHolder,
InputIterator  first,
InputIterator  last 
)

Constructs from multiple lockables.

Parameters
[in]lockableHolderWeak 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]firstFirst iterator of lockable to be added to this class.
[in]lastLast iterator of lockable to be added to this class.

Member Function Documentation

◆ lock()

template<typename Lockable >
void dart::common::MultiLockableReference< 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::MultiLockableReference< 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.


The documentation for this class was generated from the following files: