|
cheshirekow
v0.1.0
|
Points to a locked mutex and unlocks the mutex when destroyed. More...
#include <cpp_pthreads/mutex.h>
Public Member Functions | |
| ScopedLock & | operator= (ScopedLock &other) |
| assignment transfers ownership of the lock to the assignee More... | |
| ScopedLock (Mutex *mutex=0) | |
| default constructor has an empty mutex More... | |
| ScopedLock (Mutex &mutex) | |
| explicit creation, locks the mutex More... | |
| void | swap (ScopedLock &other) |
| swaps mutexes with another lock More... | |
| ~ScopedLock () | |
| move constructor transfers ownership of the lock to the new object More... | |
Private Attributes | |
| Mutex * | m_mutex |
| < the mutex being locked More... | |
Points to a locked mutex and unlocks the mutex when destroyed.
Usage:
| pthreads::ScopedLock::ScopedLock | ( | Mutex * | mutex = 0 | ) |
default constructor has an empty mutex
| pthreads::ScopedLock::ScopedLock | ( | Mutex & | mutex | ) |
explicit creation, locks the mutex
| pthreads::ScopedLock::~ScopedLock | ( | ) |
move constructor transfers ownership of the lock to the new object
unlock the mutex
| ScopedLock& pthreads::ScopedLock::operator= | ( | ScopedLock & | other | ) |
assignment transfers ownership of the lock to the assignee
If the assignee already owns a mutex, that one is unlocked
| void pthreads::ScopedLock::swap | ( | ScopedLock & | other | ) |
swaps mutexes with another lock
|
private |