| // Copyright (c) 2006- Facebook |
| // Distributed under the Thrift Software License |
| // See accompanying file LICENSE or visit the Thrift site at: |
| // http://developers.facebook.com/thrift/ |
| namespace facebook { namespace thrift { namespace concurrency { |
| * Implementation of Mutex class using POSIX mutex |
| impl() : initialized_(false) { |
| assert(pthread_mutex_init(&pthread_mutex_, NULL) == 0); |
| assert(pthread_mutex_destroy(&pthread_mutex_) == 0); |
| void lock() const { pthread_mutex_lock(&pthread_mutex_); } |
| void unlock() const { pthread_mutex_unlock(&pthread_mutex_); } |
| mutable pthread_mutex_t pthread_mutex_; |
| mutable bool initialized_; |
| Mutex::Mutex() : impl_(new Mutex::impl()) {} |
| void Mutex::lock() const { impl_->lock(); } |
| void Mutex::unlock() const { impl_->unlock(); } |
| }}} // facebook::thrift::concurrency |