Lines Matching defs:Mutex

54 class Mutex {
56 // Create a Mutex that is not held by anybody.
57 inline Mutex();
60 inline ~Mutex();
70 inline void ReaderUnlock(); // Release a read share of this Mutex
78 // Catch the error of writing Mutex when intending MutexLock.
79 Mutex(Mutex *ignored);
81 Mutex(const Mutex&);
82 void operator=(const Mutex&);
85 // Now the implementation of Mutex for various systems
99 Mutex::Mutex() : mutex_(0) { }
100 Mutex::~Mutex() { assert(mutex_ == 0); }
101 void Mutex::Lock() { assert(--mutex_ == -1); }
102 void Mutex::Unlock() { assert(mutex_++ == -1); }
103 bool Mutex::TryLock() { if (mutex_) return false; Lock(); return true; }
104 void Mutex::ReaderLock() { assert(++mutex_ > 0); }
105 void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
112 Mutex::Mutex() { SAFE_PTHREAD(pthread_rwlock_init(&mutex_, NULL)); }
113 Mutex::~Mutex() { SAFE_PTHREAD(pthread_rwlock_destroy(&mutex_)); }
114 void Mutex::Lock() { SAFE_PTHREAD(pthread_rwlock_wrlock(&mutex_)); }
115 void Mutex::Unlock() { SAFE_PTHREAD(pthread_rwlock_unlock(&mutex_)); }
116 bool Mutex::TryLock() { return pthread_rwlock_trywrlock(&mutex_) == 0; }
117 void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock(&mutex_)); }
118 void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock(&mutex_)); }
127 Mutex::Mutex() { SAFE_PTHREAD(pthread_mutex_init(&mutex_, NULL)); }
128 Mutex::~Mutex() { SAFE_PTHREAD(pthread_mutex_destroy(&mutex_)); }
129 void Mutex::Lock() { SAFE_PTHREAD(pthread_mutex_lock(&mutex_)); }
130 void Mutex::Unlock() { SAFE_PTHREAD(pthread_mutex_unlock(&mutex_)); }
131 bool Mutex::TryLock() { return pthread_mutex_trylock(&mutex_) == 0; }
132 void Mutex::ReaderLock() { Lock(); } // we don't have read-write locks
133 void Mutex::ReaderUnlock() { Unlock(); }
138 Mutex::Mutex() { InitializeCriticalSection(&mutex_); }
139 Mutex::~Mutex() { DeleteCriticalSection(&mutex_); }
140 void Mutex::Lock() { EnterCriticalSection(&mutex_); }
141 void Mutex::Unlock() { LeaveCriticalSection(&mutex_); }
142 bool Mutex::TryLock() { return TryEnterCriticalSection(&mutex_) != 0; }
143 void Mutex::ReaderLock() { Lock(); } // we don't have read-write locks
144 void Mutex::ReaderUnlock() { Unlock(); }
155 explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
158 Mutex * const mu_;
167 explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
170 Mutex * const mu_;
178 explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); }
181 Mutex * const mu_;
205 static Mutex name