PCL
pcl::AutoLock Class Reference

Automatic mutex lock/unlock. More...

#include <AutoLock.h>

Public Member Functions

 AutoLock (AutoLock &&x)
 
 AutoLock (const AutoLock &)=delete
 
 AutoLock (pcl::Mutex &mutex)
 
 ~AutoLock ()
 
void Lock ()
 
AutoLockoperator= (AutoLock &&)=delete
 
AutoLockoperator= (const AutoLock &)=delete
 
void Unlock ()
 

Detailed Description

AutoLock is a convenience class that simplifies using Mutex objects to protect code or data that can be accessed by multiple threads.

An AutoLock object locks a Mutex object upon construction and unlocks it upon destruction. This ensures that the state of the Mutex object will always be well defined, and that it will never be left locked, even in critical situations involving multiple function return points and exceptions.

See also
AutoLockCounter, Mutex

Definition at line 83 of file AutoLock.h.

Constructor & Destructor Documentation

◆ AutoLock() [1/3]

pcl::AutoLock::AutoLock ( pcl::Mutex mutex)
inlineexplicit

Constructs an AutoLock object to monitor a specified Mutex object.

Parameters
mutexA Mutex object that will be monitored by this AutoLock instance.

The specified mutex object will be locked by this constructor. It will be unlocked automatically when this AutoLock object gets out of scope, or if it is destroyed explicitly.

Definition at line 97 of file AutoLock.h.

◆ AutoLock() [2/3]

pcl::AutoLock::AutoLock ( AutoLock &&  x)
inline

Move constructor.

Definition at line 106 of file AutoLock.h.

◆ ~AutoLock()

pcl::AutoLock::~AutoLock ( )
inline

Destroys this AutoLock object.

If the monitored mutex object (that was specified in the constructor) is locked, it is unlocked by this destructor.

Definition at line 119 of file AutoLock.h.

◆ AutoLock() [3/3]

pcl::AutoLock::AutoLock ( const AutoLock )
delete

Copy constructor. This constructor is disabled because AutoLock objects cannot be copied.

Member Function Documentation

◆ Lock()

void pcl::AutoLock::Lock ( )
inline

Locks the monitored mutex object, if it has not been previously locked by this object.

Definition at line 147 of file AutoLock.h.

◆ operator=() [1/2]

AutoLock& pcl::AutoLock::operator= ( AutoLock &&  )
delete

Move assignment. This operator is disabled because AutoLock objects cannot be move-assigned.

◆ operator=() [2/2]

AutoLock& pcl::AutoLock::operator= ( const AutoLock )
delete

Copy assignment. This operator is disabled because AutoLock objects cannot be copied.

◆ Unlock()

void pcl::AutoLock::Unlock ( )
inline

Unlocks the monitored mutex object, if it has been previously locked by this object.

Definition at line 158 of file AutoLock.h.


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