OSAPIMutexLocker Class
The OSAPIMutexLocker is used for handling automatic unlocking of a mutex when it goes out of scope. More...
Header: | #include <OSAPI/Process/OSAPISemaphore.h> |
Public Functions
OSAPIMutexLocker(const OSAPIMutex &mutex, const char *pzCaller = "") | |
virtual | ~OSAPIMutexLocker() |
bool | IsLocked() |
void | Lock() |
void | Release() |
Detailed Description
The OSAPIMutexLocker is used for handling automatic unlocking of a mutex when it goes out of scope.
A class for handling automatic unlocking of a mutex when it goes out of scope. Note that if the mutex is already released when it goes out of scope, Release() on the mutex will not be called.
Excellent for using in code with several exit-options or code that might throw exceptions.
Usage
{ OSAPIMutexLocker locker(m_mutex); // will lock m_mutex ... ... } // Mutex will be unlocked automaticallly here as the OSAPIMutexLocker instance goes out of scope.
See also OSAPIMutex.
Member Function Documentation
OSAPIMutexLocker::OSAPIMutexLocker(const OSAPIMutex &mutex, const char *pzCaller = "")
Constructs an OSAPIMutexLocker
[virtual]
OSAPIMutexLocker::~OSAPIMutexLocker()
Destructs the OSAPIMutexLocker.
bool OSAPIMutexLocker::IsLocked()
Returns true
if the mutex has been locked through OSAPIMutexLocker.
void OSAPIMutexLocker::Lock()
Locks the mutex.
void OSAPIMutexLocker::Release()
Releases the mutex.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.