diff options
author | Abseil Team <absl-team@google.com> | 2024-01-24 10:08:22 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-01-24 10:09:28 -0800 |
commit | 27f15a052ba54c984faa1eb6044de59b237e6f37 (patch) | |
tree | 13b5643f9c30a795915fcb86f7c16649a8194f8c /absl | |
parent | 6dda8e527f19a6508ab855641914945a20d6b6df (diff) |
Use absl::NoDestructor for global HashtablezSampler.
PiperOrigin-RevId: 601156448
Change-Id: Id6d19bda7eb3acee11cfab3a95e611996d6ef4cc
Diffstat (limited to 'absl')
-rw-r--r-- | absl/container/BUILD.bazel | 1 | ||||
-rw-r--r-- | absl/container/CMakeLists.txt | 1 | ||||
-rw-r--r-- | absl/container/internal/hashtablez_sampler.cc | 3 |
3 files changed, 4 insertions, 1 deletions
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index 0ba2fa76..fda866a5 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel @@ -563,6 +563,7 @@ cc_library( "//absl/base", "//absl/base:config", "//absl/base:core_headers", + "//absl/base:no_destructor", "//absl/base:raw_logging_internal", "//absl/debugging:stacktrace", "//absl/memory", diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt index 128cc0e9..449a2cad 100644 --- a/absl/container/CMakeLists.txt +++ b/absl/container/CMakeLists.txt @@ -602,6 +602,7 @@ absl_cc_library( absl::base absl::config absl::exponential_biased + absl::no_destructor absl::raw_logging_internal absl::sample_recorder absl::synchronization diff --git a/absl/container/internal/hashtablez_sampler.cc b/absl/container/internal/hashtablez_sampler.cc index 79a0973a..b21beef0 100644 --- a/absl/container/internal/hashtablez_sampler.cc +++ b/absl/container/internal/hashtablez_sampler.cc @@ -24,6 +24,7 @@ #include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" +#include "absl/base/no_destructor.h" #include "absl/debugging/stacktrace.h" #include "absl/memory/memory.h" #include "absl/profiling/internal/exponential_biased.h" @@ -64,7 +65,7 @@ ABSL_PER_THREAD_TLS_KEYWORD SamplingState global_next_sample = {0, 0}; #endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) HashtablezSampler& GlobalHashtablezSampler() { - static auto* sampler = new HashtablezSampler(); + static absl::NoDestructor<HashtablezSampler> sampler; return *sampler; } |