Class that implements a lock. The class wraps around pthread_mutex_t and adds some safeguards. More...
#include <paraPthLock.h>
Public Member Functions | |
Lock () | |
Initialize this lock. More... | |
~Lock () | |
Destroy this lock. More... | |
void | lock () |
Acquire this lock. The function sets the internal file/line (debugging) fields to generic values. More... | |
void | lock (char const *f, int l) |
Acquire this lock. The function sets the internal file/line (debugging) fields to the values specified by f and l. More... | |
void | unlock () |
Release this lock. More... | |
Private Member Functions | |
Lock (Lock const &) | |
Code like this pthread_mutex_t m1, m2; pthread_mutex_init(&m1, 0); m2 = m1; results in undefined behavior. So we must never assign one instance of pthread_mutex_t to another. To do that we make the copy constructor and the assignment operator private and do not implement it. This way locks can be passed around only by reference or pointer. More... | |
Lock & | operator= (Lock const &) |
Private Attributes | |
pthread_mutex_t | mtx |
The low-level mutex that implements this lock. More... | |
char const * | file |
File in which the lock was last acquired (debugging). More... | |
int | line |
Line at which the lock was last acquired (debugging). More... | |
Friends | |
class | ConditionVariable |
Class that implements a lock. The class wraps around pthread_mutex_t and adds some safeguards.
Definition at line 82 of file paraPthLock.h.
Code like this pthread_mutex_t m1, m2; pthread_mutex_init(&m1, 0); m2 = m1; results in undefined behavior. So we must never assign one instance of pthread_mutex_t to another. To do that we make the copy constructor and the assignment operator private and do not implement it. This way locks can be passed around only by reference or pointer.
Lock | ( | ) |
~Lock | ( | ) |
void lock | ( | ) |
Acquire this lock. The function sets the internal file/line (debugging) fields to generic values.
Definition at line 133 of file paraPthLock.h.
References Lock::lock().
Referenced by ConditionVariable::lock(), Lock::lock(), ParaCommPth::lockApp(), LockRAII::LockRAII(), and ParaCommPth::lockRank().
void lock | ( | char const * | f, |
int | l | ||
) |
Acquire this lock. The function sets the internal file/line (debugging) fields to the values specified by f and l.
f | file name |
l | line number |
Definition at line 144 of file paraPthLock.h.
References Lock::file, Lock::line, LOCK_VERBOSE, and Lock::mtx.
void unlock | ( | ) |
Release this lock.
Definition at line 161 of file paraPthLock.h.
References Lock::file, Lock::line, LOCK_VERBOSE, and Lock::mtx.
Referenced by ConditionVariable::unlock(), ParaCommPth::unlockApp(), ParaCommPth::unlockRank(), and LockRAII::~LockRAII().
|
friend |
Definition at line 84 of file paraPthLock.h.
|
private |
File in which the lock was last acquired (debugging).
Definition at line 87 of file paraPthLock.h.
Referenced by Lock::lock(), and Lock::unlock().
|
private |
Line at which the lock was last acquired (debugging).
Definition at line 88 of file paraPthLock.h.
Referenced by Lock::lock(), and Lock::unlock().
|
private |
The low-level mutex that implements this lock.
Definition at line 86 of file paraPthLock.h.
Referenced by Lock::Lock(), Lock::lock(), Lock::unlock(), ConditionVariable::wait(), and Lock::~Lock().