aboutsummaryrefslogtreecommitdiff
path: root/absl/container/internal/hashtablez_sampler.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2024-01-24 10:08:22 -0800
committerCopybara-Service <copybara-worker@google.com>2024-01-24 10:09:28 -0800
commit27f15a052ba54c984faa1eb6044de59b237e6f37 (patch)
tree13b5643f9c30a795915fcb86f7c16649a8194f8c /absl/container/internal/hashtablez_sampler.cc
parent6dda8e527f19a6508ab855641914945a20d6b6df (diff)
downloadabseil-27f15a052ba54c984faa1eb6044de59b237e6f37.tar.gz
abseil-27f15a052ba54c984faa1eb6044de59b237e6f37.tar.bz2
abseil-27f15a052ba54c984faa1eb6044de59b237e6f37.zip
Use absl::NoDestructor for global HashtablezSampler.
PiperOrigin-RevId: 601156448 Change-Id: Id6d19bda7eb3acee11cfab3a95e611996d6ef4cc
Diffstat (limited to 'absl/container/internal/hashtablez_sampler.cc')
-rw-r--r--absl/container/internal/hashtablez_sampler.cc3
1 files changed, 2 insertions, 1 deletions
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;
}