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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SPINLOCK_WRAPPER_H_
6 #define SPINLOCK_WRAPPER_H_
7
8 class SpinLock;
9
10 // A container class for using tcmalloc's SpinLock class.
11 // 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.
12 // #include path conflicts.
13
14 // SpinLockWrapper depends on CustomAllocator, which must be initialized before
15 // any instance of this class is created.
16 class SpinLockWrapper {
17 public:
18 SpinLockWrapper();
19 ~SpinLockWrapper();
20
21 void Lock();
22 void Unlock();
23
24 private:
25 SpinLock* lock_;
26 };
27
28 // Corresponding locker object that arranges to acquire a spinlock for the
29 // duration of a C++ scope.
30 class ScopedSpinLockHolder {
31 public:
32 explicit ScopedSpinLockHolder(SpinLockWrapper* lock) : lock_(lock) {
33 lock_->Lock();
34 }
35
36 ~ScopedSpinLockHolder() {
37 lock_->Unlock();
38 }
39
40 private:
41 SpinLockWrapper* lock_;
42 };
43
44 #endif // SPINLOCK_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698