#include <thread>
#include "port/port.h"
-namespace rocksdb {
+namespace ROCKSDB_NAMESPACE {
// Helper class that locks a mutex on construction and unlocks the mutex when
// the destructor of the MutexLock object is invoked.
explicit MutexLock(port::Mutex *mu) : mu_(mu) {
this->mu_->Lock();
}
+ // No copying allowed
+ MutexLock(const MutexLock &) = delete;
+ void operator=(const MutexLock &) = delete;
+
~MutexLock() { this->mu_->Unlock(); }
private:
port::Mutex *const mu_;
- // No copying allowed
- MutexLock(const MutexLock&);
- void operator=(const MutexLock&);
};
//
explicit ReadLock(port::RWMutex *mu) : mu_(mu) {
this->mu_->ReadLock();
}
+ // No copying allowed
+ ReadLock(const ReadLock &) = delete;
+ void operator=(const ReadLock &) = delete;
+
~ReadLock() { this->mu_->ReadUnlock(); }
private:
port::RWMutex *const mu_;
- // No copying allowed
- ReadLock(const ReadLock&);
- void operator=(const ReadLock&);
};
//
class ReadUnlock {
public:
explicit ReadUnlock(port::RWMutex *mu) : mu_(mu) { mu->AssertHeld(); }
+ // No copying allowed
+ ReadUnlock(const ReadUnlock &) = delete;
+ ReadUnlock &operator=(const ReadUnlock &) = delete;
+
~ReadUnlock() { mu_->ReadUnlock(); }
private:
port::RWMutex *const mu_;
- // No copying allowed
- ReadUnlock(const ReadUnlock &) = delete;
- ReadUnlock &operator=(const ReadUnlock &) = delete;
};
//
explicit WriteLock(port::RWMutex *mu) : mu_(mu) {
this->mu_->WriteLock();
}
+ // No copying allowed
+ WriteLock(const WriteLock &) = delete;
+ void operator=(const WriteLock &) = delete;
+
~WriteLock() { this->mu_->WriteUnlock(); }
private:
port::RWMutex *const mu_;
- // No copying allowed
- WriteLock(const WriteLock&);
- void operator=(const WriteLock&);
};
//
std::atomic<bool> locked_;
};
-} // namespace rocksdb
+} // namespace ROCKSDB_NAMESPACE