From 05709fb43eea34936c9f535edcb74d5e91a0b495 Mon Sep 17 00:00:00 2001 From: costan Date: Mon, 10 Sep 2018 15:38:12 -0700 Subject: Remove InitOnce from the port API. This is not an API-breaking change, because it reduces the API that the leveldb embedder must implement. The project will build just fine against ports that still implement InitOnce. C++11 guarantees thread-safe initialization of static variables inside functions. This is a more restricted form of std::call_once or pthread_once_t (e.g., single call site), so the compiler might be able to generate better code [1]. Equally important, having less code in port_example.h makes it easier to port to other platforms. Due to the change above, this CL introduces a new approach for storing the singleton BytewiseComparatorImpl instance returned by BytewiseComparator(). The new approach avoids a dynamic memory allocation, which eliminates the false positive from LeakSanitizer reported in https://github.com/google/leveldb/issues/200 [1] https://stackoverflow.com/a/27206650/ ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=212348004 --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index d49c31e..36d6cbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,6 +149,7 @@ target_sources(leveldb "${PROJECT_SOURCE_DIR}/util/logging.cc" "${PROJECT_SOURCE_DIR}/util/logging.h" "${PROJECT_SOURCE_DIR}/util/mutexlock.h" + "${PROJECT_SOURCE_DIR}/util/no_destructor.h" "${PROJECT_SOURCE_DIR}/util/options.cc" "${PROJECT_SOURCE_DIR}/util/random.h" "${PROJECT_SOURCE_DIR}/util/status.cc" @@ -278,6 +279,7 @@ if(LEVELDB_BUILD_TESTS) leveldb_test("${PROJECT_SOURCE_DIR}/util/env_test.cc") leveldb_test("${PROJECT_SOURCE_DIR}/util/status_test.cc") + leveldb_test("${PROJECT_SOURCE_DIR}/util/no_destructor_test.cc") if(NOT BUILD_SHARED_LIBS) leveldb_test("${PROJECT_SOURCE_DIR}/db/autocompact_test.cc") -- cgit v1.2.1