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

Side by Side Diff: third_party/tcmalloc/chromium/src/base/spinlock.h

Issue 576001: Merged third_party/tcmalloc/vendor/src(google-perftools r87) into... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Removed the unnecessary printf and ASSERT(0) Created 10 years, 9 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 | Annotate | Revision Log
OLDNEW
1 /* Copyright (c) 2006, Google Inc. 1 /* Copyright (c) 2006, Google Inc.
2 * All rights reserved. 2 * All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 static const base::LinkerInitialized LINKER_INITIALIZED; // backwards compat 127 static const base::LinkerInitialized LINKER_INITIALIZED; // backwards compat
128 private: 128 private:
129 // Lock-state: 0 means unlocked; 1 means locked with no waiters; values 129 // Lock-state: 0 means unlocked; 1 means locked with no waiters; values
130 // greater than 1 indicate locked with waiters, where the value is the time 130 // greater than 1 indicate locked with waiters, where the value is the time
131 // the first waiter started waiting and is used for contention profiling. 131 // the first waiter started waiting and is used for contention profiling.
132 volatile Atomic32 lockword_; 132 volatile Atomic32 lockword_;
133 133
134 void SlowLock(); 134 void SlowLock();
135 void SlowUnlock(int64 wait_timestamp); 135 void SlowUnlock(int64 wait_timestamp);
136 136
137 DISALLOW_EVIL_CONSTRUCTORS(SpinLock); 137 DISALLOW_COPY_AND_ASSIGN(SpinLock);
138 }; 138 };
139 139
140 // Corresponding locker object that arranges to acquire a spinlock for 140 // Corresponding locker object that arranges to acquire a spinlock for
141 // the duration of a C++ scope. 141 // the duration of a C++ scope.
142 class SCOPED_LOCKABLE SpinLockHolder { 142 class SCOPED_LOCKABLE SpinLockHolder {
143 private: 143 private:
144 SpinLock* lock_; 144 SpinLock* lock_;
145 public: 145 public:
146 inline explicit SpinLockHolder(SpinLock* l) EXCLUSIVE_LOCK_FUNCTION(l) 146 inline explicit SpinLockHolder(SpinLock* l) EXCLUSIVE_LOCK_FUNCTION(l)
147 : lock_(l) { 147 : lock_(l) {
148 l->Lock(); 148 l->Lock();
149 } 149 }
150 // TODO(csilvers): uncomment the annotation when we figure out how to 150 // TODO(csilvers): uncomment the annotation when we figure out how to
151 // support this macro with 0 args (see thread_annotations.h) 151 // support this macro with 0 args (see thread_annotations.h)
152 inline ~SpinLockHolder() /*UNLOCK_FUNCTION()*/ { lock_->Unlock(); } 152 inline ~SpinLockHolder() /*UNLOCK_FUNCTION()*/ { lock_->Unlock(); }
153 }; 153 };
154 // Catch bug where variable name is omitted, e.g. SpinLockHolder (&lock); 154 // Catch bug where variable name is omitted, e.g. SpinLockHolder (&lock);
155 #define SpinLockHolder(x) COMPILE_ASSERT(0, spin_lock_decl_missing_var_name) 155 #define SpinLockHolder(x) COMPILE_ASSERT(0, spin_lock_decl_missing_var_name)
156 156
157 157
158 #endif // BASE_SPINLOCK_H_ 158 #endif // BASE_SPINLOCK_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/base/low_level_alloc.cc ('k') | third_party/tcmalloc/chromium/src/base/sysinfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698