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

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: Fix style, comments, RAW_CHECK in stl_allocator.h 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..c2f604ffafed93039475b8f3d5bf98a626c167bd
--- /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 avoids users of this class to directly include those classes, causing
jar (doing other things) 2015/08/21 02:48:43 nit: typos in sentence. I don't know what you mea
Simon Que 2015/08/21 21:59:20 Done.
+// #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