10 #ifndef READWRITELOCK_H_
11 #define READWRITELOCK_H_
31 [=](pthread_mutex_t& mutex) ->
int {
return pthread_mutex_lock(&mutex);};
33 [=](pthread_mutex_t& mutex) ->
int {
return pthread_mutex_unlock(&mutex);};
36 [=](pthread_rwlock_t& mutex) ->
int {
return pthread_rwlock_rdlock(&mutex);};
38 [=](pthread_rwlock_t& mutex) ->
int {
return pthread_rwlock_unlock(&mutex);};
41 [=](pthread_rwlock_t& mutex) ->
int {
return pthread_rwlock_rdlock(&mutex);};
43 [=](pthread_rwlock_t& mutex) ->
int {
return pthread_rwlock_unlock(&mutex);};
static int initFunctions()
MutexLock(T &m, std::function< int(T &)> &lock, std::function< int(T &)> &unlock)
Construct and lock mutex.
static std::function< int(pthread_rwlock_t &)> readLockLock
PlainLock(pthread_mutex_t &m)
virtual ~MutexLock()
Destruct and unlock mutex.
static bool functionsAreInitialized
static std::function< int(pthread_rwlock_t &)> writeLockLock
virtual int unlock()
Explicitly unlock existing mutex.
ReadLock(pthread_rwlock_t &m)
static std::function< int(pthread_rwlock_t &)> readLockUnock
static std::function< int(pthread_mutex_t &)> plainLockLock
static std::function< int(pthread_mutex_t &)> plainLockUnlock
WriteLock(pthread_rwlock_t &m)
virtual int lock()
Explicitly lock mutex, need to make sure you do not get into racing condition.
std::function< int(T &)> lockFunc
std::function< int(T &)> unlockFunc
static std::function< int(pthread_rwlock_t &)> writeLockUnlock