• Home
  • Raw
  • Download

Lines Matching full:mutex

9  * A simple mutex wrapper, supporting locks and read-write locks.
28 #include <mutex>
29 typedef std::mutex MutexType;
34 class Mutex {
36 inline Mutex();
37 inline ~Mutex();
45 inline void ReaderUnlock(); // Release a read share of this Mutex
52 // Catch the error of writing Mutex when intending MutexLock.
53 Mutex(Mutex *ignored);
55 Mutex(const Mutex&) = delete;
56 Mutex& operator=(const Mutex&) = delete;
66 Mutex::Mutex() { SAFE_PTHREAD(pthread_rwlock_init(&mutex_, NULL)); } in Mutex() function
67 Mutex::~Mutex() { SAFE_PTHREAD(pthread_rwlock_destroy(&mutex_)); } in ~Mutex()
68 void Mutex::Lock() { SAFE_PTHREAD(pthread_rwlock_wrlock(&mutex_)); } in Lock()
69 void Mutex::Unlock() { SAFE_PTHREAD(pthread_rwlock_unlock(&mutex_)); } in Unlock()
70 void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock(&mutex_)); } in ReaderLock()
71 void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock(&mutex_)); } in ReaderUnlock()
77 Mutex::Mutex() { } in Mutex() function
78 Mutex::~Mutex() { } in ~Mutex()
79 void Mutex::Lock() { mutex_.lock(); } in Lock()
80 void Mutex::Unlock() { mutex_.unlock(); } in Unlock()
81 void Mutex::ReaderLock() { Lock(); } // C++11 doesn't have std::shared_mutex. in ReaderLock()
82 void Mutex::ReaderUnlock() { Unlock(); } in ReaderUnlock()
92 explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); } in MutexLock()
95 Mutex * const mu_;
104 explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); } in ReaderMutexLock()
107 Mutex * const mu_;
115 explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); } in WriterMutexLock()
118 Mutex * const mu_;