UaMutexLocker Class Reference

Auto lock and unlock class for Mutex class. The UaMutexLocker class is a convenience class that simplifies locking and unlocking mutexes. Locking and unlocking an UaMutex in complex functions and statements or in exception handling code is error-prone and difficult to debug. UaMutexLocker can be used in such situations to ensure that the state of the mutex is always well-defined. UaMutexLocker should be created within a function where an UaMutex needs to be locked. The mutex is locked when UaMutexLocker is created. You can unlock the mutex with unlock(). If locked, the mutex will be unlocked when the UaMutexLocker is destroyed. It is not possible to create plane copies of this Class. More...

#include <uamutex.h>

Collaboration diagram for UaMutexLocker:

List of all members.


Public Member Functions

 UaMutexLocker (UaMutex *pMutex)
 ~UaMutexLocker ()
void unlock ()
void lock (UaMutex *pMutex)

Detailed Description

Auto lock and unlock class for Mutex class. The UaMutexLocker class is a convenience class that simplifies locking and unlocking mutexes. Locking and unlocking an UaMutex in complex functions and statements or in exception handling code is error-prone and difficult to debug. UaMutexLocker can be used in such situations to ensure that the state of the mutex is always well-defined. UaMutexLocker should be created within a function where an UaMutex needs to be locked. The mutex is locked when UaMutexLocker is created. You can unlock the mutex with unlock(). If locked, the mutex will be unlocked when the UaMutexLocker is destroyed. It is not possible to create plane copies of this Class.

UaMutexLocker


Constructor & Destructor Documentation

UaMutexLocker::UaMutexLocker ( UaMutex pMutex  ) 

construction Constructs a UaMutexLocker object and locks passed pMutex to block access to a resource. The mutex will be unlocked when the UaMutexLocker is destroyed.

Parameters:
pMutex the mutex to lock.

UaMutexLocker::~UaMutexLocker (  ) 

destruction Destroys the UaMutexLocker object and unlocks the mutex object that was locked in the constructor.


Member Function Documentation

void UaMutexLocker::unlock (  ) 

Unlocks the mutex.

void UaMutexLocker::lock ( UaMutex pMutex  ) 

Locks the mutex.

Parameters:
pMutex the mutex to lock.


The documentation for this class was generated from the following files:
  • src/uabase/uabasecpp/uamutex.h
  • src/uabase/uabasecpp/uamutex.cpp