PIP 5.5.3
Platform-Independent Primitives
Public Member Functions | List of all members
PIMutexLocker Class Reference

PIMutex autolocker More...

#include <pimutex.h>

Public Member Functions

 PIMutexLocker (PIMutex &m, bool condition=true)
 Constructs and lock "m" if "condition" is true.
 
 ~PIMutexLocker ()
 Unlock "m" if "condition" was true.
 

Detailed Description

PIMutex autolocker

When a PIMutexLocker object is created, it attempts to lock the mutex it is given, if "condition" true. When control leaves the scope in which the PIMutexLocker object was created, the PIMutexLocker is destructed and the mutex is released, if "condition" was true.

If "condition" false this class do nothing.

The PIMutexLocker class is non-copyable.

// critical section start
{
PIMutexLocker locker(mutex);
// ... your code here
}
// critical section end
PIMutex autolocker
Definition: pimutex.h:67