Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: third_party/tcmalloc/chromium/src/gperftools/spin_lock_wrapper.h

Issue 986503002: components/metrics: Add runtime memory leak detector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: LeakDetectorImpl stores addrs as uintptr_t; Implement move semantics for RankedList Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/chromium/src/gperftools/spin_lock_wrapper.h
diff --git a/third_party/tcmalloc/chromium/src/gperftools/spin_lock_wrapper.h b/third_party/tcmalloc/chromium/src/gperftools/spin_lock_wrapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..b33a79797b71182d22336118bdb24760aaa0d3e3
--- /dev/null
+++ b/third_party/tcmalloc/chromium/src/gperftools/spin_lock_wrapper.h
@@ -0,0 +1,44 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SPINLOCK_WRAPPER_H_
+#define SPINLOCK_WRAPPER_H_
+
+class SpinLock;
+
+// A container class for using tcmalloc's SpinLock class.
+// This allows users of this class to avoid including base/spinlock.h, which
+// causes #include path conflicts.
+
+// SpinLockWrapper depends on CustomAllocator, which must be initialized before
+// any instance of this class is created.
+class SpinLockWrapper {
+ public:
+ SpinLockWrapper();
+ ~SpinLockWrapper();
+
+ void Lock();
+ void Unlock();
+
+ private:
+ SpinLock* lock_;
+};
+
+// Corresponding locker object that arranges to acquire a spinlock for the
+// duration of a C++ scope.
+class ScopedSpinLockHolder {
+ public:
+ explicit ScopedSpinLockHolder(SpinLockWrapper* lock) : lock_(lock) {
+ lock_->Lock();
+ }
+
+ ~ScopedSpinLockHolder() {
+ lock_->Unlock();
+ }
+
+ private:
+ SpinLockWrapper* lock_;
+};
+
+#endif // SPINLOCK_WRAPPER_H_

Powered by Google App Engine
This is Rietveld 408576698