YARP  2.3.70
Yet Another Robot Platform
yarp::os::AbstractLockGuard< Lockable > Class Template Reference

This class is a mutex wrapper that provides a convenient RAII-style mechanism for owning a mutex for the duration of a scoped block. More...

#include <yarp/os/LockGuard.h>

Public Member Functions

 AbstractLockGuard (Lockable &_lock)
 Acquires ownership of the given mutex _mutex. More...
 
 ~AbstractLockGuard ()
 destructs the LockGuard object, unlocks the underlying mutex More...
 

Private Member Functions

 AbstractLockGuard (const AbstractLockGuard &)
 Copy constructor is disabled. More...
 
AbstractLockGuardoperator= (const AbstractLockGuard &)
 Assignment operator is disabled. More...
 

Private Attributes

Lockable & lock
 underlining mutex More...
 

Detailed Description

template<typename Lockable>
class yarp::os::AbstractLockGuard< Lockable >

This class is a mutex wrapper that provides a convenient RAII-style mechanism for owning a mutex for the duration of a scoped block.

When a LockGuard object is created, it attempts to take ownership of the mutex it is given. When control leaves the scope in which the LockGuard object was created, the LockGuard is destructed and the mutex is released. The lock_guard class is non-copyable.

Definition at line 15 of file LockGuard.h.

Constructor & Destructor Documentation

◆ AbstractLockGuard() [1/2]

template<typename Lockable >
yarp::os::AbstractLockGuard< Lockable >::AbstractLockGuard ( Lockable &  _lock)
explicit

Acquires ownership of the given mutex _mutex.

The behavior is undefined if _mutex is destroyed before the LockGuard object is.

Parameters
_mutexthe mutex which will be locked

Definition at line 62 of file LockGuard.h.

◆ ~AbstractLockGuard()

template<typename Lockable >
yarp::os::AbstractLockGuard< Lockable >::~AbstractLockGuard ( )

destructs the LockGuard object, unlocks the underlying mutex

Definition at line 69 of file LockGuard.h.

◆ AbstractLockGuard() [2/2]

template<typename Lockable >
yarp::os::AbstractLockGuard< Lockable >::AbstractLockGuard ( const AbstractLockGuard< Lockable > &  lg)
private

Copy constructor is disabled.

Definition at line 75 of file LockGuard.h.

Member Function Documentation

◆ operator=()

template<typename Lockable >
yarp::os::AbstractLockGuard< Lockable > & yarp::os::AbstractLockGuard< Lockable >::operator= ( const AbstractLockGuard< Lockable > &  )
private

Assignment operator is disabled.

Definition at line 79 of file LockGuard.h.

Member Data Documentation

◆ lock

template<typename Lockable >
Lockable& yarp::os::AbstractLockGuard< Lockable >::lock
private

underlining mutex

Definition at line 56 of file LockGuard.h.


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