#include <UMutex.h>
Public Member Functions | |
UScopeMutex (const UMutex &mutex) | |
UScopeMutex (UMutex *mutex) | |
~UScopeMutex () | |
Private Attributes | |
const UMutex & | mutex_ |
Automatically lock the referenced mutex on constructor and unlock mutex on destructor.
Example:
UMutex m; // Mutex shared with another thread(s). ... int myMethod() { UScopeMutex sm(m); // automatically lock the mutex m if(cond1) { return 1; // automatically unlock the mutex m } else if(cond2) { return 2; // automatically unlock the mutex m } return 0; // automatically unlock the mutex m }
UScopeMutex::UScopeMutex | ( | const UMutex & | mutex | ) | [inline] |
UScopeMutex::UScopeMutex | ( | UMutex * | mutex | ) | [inline] |
UScopeMutex::~UScopeMutex | ( | ) | [inline] |
const UMutex& UScopeMutex::mutex_ [private] |