summaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
authorChris Mumford <cmumford@google.com>2019-05-03 09:31:18 -0700
committerChris Mumford <cmumford@google.com>2019-05-03 09:48:57 -0700
commit9bd23c767601a2420478eec158927882b879bada (patch)
tree1b40c3712c8d882bab5d339a572e56527c145b56 /helpers
parentc784d63b931d07895833fb80185b10d44ad63cce (diff)
downloadleveldb-9bd23c767601a2420478eec158927882b879bada.tar.gz
Correct class/structure declaration order.
1. Correct the class/struct declaration order to be IAW the Google C++ style guide[1]. 2. For non-copyable classes, switched from non-implemented private methods to explicitly deleted[2] methods. 3. Minor const and member initialization fixes. [1] https://google.github.io/styleguide/cppguide.html#Declaration_Order [2] http://eel.is/c++draft/dcl.fct.def.delete PiperOrigin-RevId: 246521844
Diffstat (limited to 'helpers')
-rw-r--r--helpers/memenv/memenv.cc13
-rw-r--r--helpers/memenv/memenv_test.cc4
2 files changed, 9 insertions, 8 deletions
diff --git a/helpers/memenv/memenv.cc b/helpers/memenv/memenv.cc
index 58dc538..b6b790c 100644
--- a/helpers/memenv/memenv.cc
+++ b/helpers/memenv/memenv.cc
@@ -27,6 +27,10 @@ class FileState {
// and the caller must call Ref() at least once.
FileState() : refs_(0), size_(0) {}
+ // No copying allowed.
+ FileState(const FileState&) = delete;
+ FileState& operator=(const FileState&) = delete;
+
// Increase the reference count.
void Ref() {
MutexLock lock(&refs_mutex_);
@@ -133,21 +137,17 @@ class FileState {
}
private:
+ enum { kBlockSize = 8 * 1024 };
+
// Private since only Unref() should be used to delete it.
~FileState() { Truncate(); }
- // No copying allowed.
- FileState(const FileState&);
- void operator=(const FileState&);
-
port::Mutex refs_mutex_;
int refs_ GUARDED_BY(refs_mutex_);
mutable port::Mutex blocks_mutex_;
std::vector<char*> blocks_ GUARDED_BY(blocks_mutex_);
uint64_t size_ GUARDED_BY(blocks_mutex_);
-
- enum { kBlockSize = 8 * 1024 };
};
class SequentialFileImpl : public SequentialFile {
@@ -380,6 +380,7 @@ class InMemoryEnv : public EnvWrapper {
private:
// Map from filenames to FileState objects, representing a simple file system.
typedef std::map<std::string, FileState*> FileSystem;
+
port::Mutex mutex_;
FileSystem file_map_ GUARDED_BY(mutex_);
};
diff --git a/helpers/memenv/memenv_test.cc b/helpers/memenv/memenv_test.cc
index a0a9469..94ad06b 100644
--- a/helpers/memenv/memenv_test.cc
+++ b/helpers/memenv/memenv_test.cc
@@ -16,10 +16,10 @@ namespace leveldb {
class MemEnvTest {
public:
- Env* env_;
-
MemEnvTest() : env_(NewMemEnv(Env::Default())) {}
~MemEnvTest() { delete env_; }
+
+ Env* env_;
};
TEST(MemEnvTest, Basics) {