Lock guard class. More...
#include <tinythread.h>
Public Member Functions | |
lock_guard (mutex_type &aMutex) | |
The constructor locks the mutex. | |
~lock_guard () | |
The destructor unlocks the mutex. |
Lock guard class.
The constructor locks the mutex, and the destructor unlocks the mutex, so the mutex will automatically be unlocked when the lock guard goes out of scope. Example usage:
mutex m; int counter; void increment() { lock_guard<mutex> guard(m); ++ counter; }