diff options
author | costan <costan@google.com> | 2019-03-11 13:04:53 -0700 |
---|---|---|
committer | Chris Mumford <cmumford@google.com> | 2019-03-11 13:41:25 -0700 |
commit | 7d8e41e49b8fddda66a2c5f0a6a47f1a916e8d26 (patch) | |
tree | 0a5556aaf20ba27bd6ea0ab3792d1366e60b2f81 /db/db_impl.h | |
parent | dd906262fd364c08a652dfa914f9995f6b7608a9 (diff) | |
download | leveldb-7d8e41e49b8fddda66a2c5f0a6a47f1a916e8d26.tar.gz |
leveldb: Replace AtomicPointer with std::atomic.
This CL removes AtomicPointer from leveldb's port interface. Its usage is replaced with std::atomic<> from the C++11 standard library.
AtomicPointer was used to wrap flags, numbers, and pointers, so its instances are replaced with std::atomic<bool>, std::atomic<int>, std::atomic<size_t> and std::atomic<Node*>.
This CL does not revise the memory ordering. AtomicPointer's methods are replaced mechanically with their std::atomic equivalents, even when the underlying usage is incorrect. (Example: DBImpl::has_imm_ is written using release stores, even though it is always read using relaxed ordering.) Revising the memory ordering is left for future CLs.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=237865146
Diffstat (limited to 'db/db_impl.h')
-rw-r--r-- | db/db_impl.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/db/db_impl.h b/db/db_impl.h index 00e800a..ca00d42 100644 --- a/db/db_impl.h +++ b/db/db_impl.h @@ -5,8 +5,11 @@ #ifndef STORAGE_LEVELDB_DB_DB_IMPL_H_ #define STORAGE_LEVELDB_DB_DB_IMPL_H_ +#include <atomic> #include <deque> #include <set> +#include <string> + #include "db/dbformat.h" #include "db/log_writer.h" #include "db/snapshot.h" @@ -136,11 +139,11 @@ class DBImpl : public DB { // State below is protected by mutex_ port::Mutex mutex_; - port::AtomicPointer shutting_down_; + std::atomic<bool> shutting_down_; port::CondVar background_work_finished_signal_ GUARDED_BY(mutex_); MemTable* mem_; MemTable* imm_ GUARDED_BY(mutex_); // Memtable being compacted - port::AtomicPointer has_imm_; // So bg thread can detect non-null imm_ + std::atomic<bool> has_imm_; // So bg thread can detect non-null imm_ WritableFile* logfile_; uint64_t logfile_number_ GUARDED_BY(mutex_); log::Writer* log_; |