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 /util/arena.cc | |
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 'util/arena.cc')
-rw-r--r-- | util/arena.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/util/arena.cc b/util/arena.cc index a0338bf..a496ad0 100644 --- a/util/arena.cc +++ b/util/arena.cc @@ -3,7 +3,6 @@ // found in the LICENSE file. See the AUTHORS file for names of contributors. #include "util/arena.h" -#include <assert.h> namespace leveldb { @@ -60,8 +59,8 @@ char* Arena::AllocateAligned(size_t bytes) { char* Arena::AllocateNewBlock(size_t block_bytes) { char* result = new char[block_bytes]; blocks_.push_back(result); - memory_usage_.NoBarrier_Store( - reinterpret_cast<void*>(MemoryUsage() + block_bytes + sizeof(char*))); + memory_usage_.fetch_add(block_bytes + sizeof(char*), + std::memory_order_relaxed); return result; } |