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

Side by Side Diff: base/synchronization/lock.h

Issue 6725001: Base: First pass at having base.dll: definition of (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_SYNCHRONIZATION_LOCK_H_ 5 #ifndef BASE_SYNCHRONIZATION_LOCK_H_
6 #define BASE_SYNCHRONIZATION_LOCK_H_ 6 #define BASE_SYNCHRONIZATION_LOCK_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/base_api.h"
9 #include "base/synchronization/lock_impl.h" 10 #include "base/synchronization/lock_impl.h"
10 #include "base/threading/platform_thread.h" 11 #include "base/threading/platform_thread.h"
11 12
12 namespace base { 13 namespace base {
13 14
14 // A convenient wrapper for an OS specific critical section. The only real 15 // A convenient wrapper for an OS specific critical section. The only real
15 // intelligence in this class is in debug mode for the support for the 16 // intelligence in this class is in debug mode for the support for the
16 // AssertAcquired() method. 17 // AssertAcquired() method.
17 class Lock { 18 class BASE_API Lock {
wtc 2011/03/23 22:05:12 Can you summarize the rules for determining which
rvargas (doing something else) 2011/03/23 22:59:04 The basic rule is that anything that is not direct
18 public: 19 public:
19 #if defined(NDEBUG) // Optimized wrapper implementation 20 #if defined(NDEBUG) // Optimized wrapper implementation
20 Lock() : lock_() {} 21 Lock() : lock_() {}
21 ~Lock() {} 22 ~Lock() {}
22 void Acquire() { lock_.Lock(); } 23 void Acquire() { lock_.Lock(); }
23 void Release() { lock_.Unlock(); } 24 void Release() { lock_.Unlock(); }
24 25
25 // If the lock is not held, take it and return true. If the lock is already 26 // If the lock is not held, take it and return true. If the lock is already
26 // held by another thread, immediately return false. This must not be called 27 // held by another thread, immediately return false. This must not be called
27 // by a thread already holding the lock (what happens is undefined and an 28 // by a thread already holding the lock (what happens is undefined and an
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 123 }
123 124
124 private: 125 private:
125 Lock& lock_; 126 Lock& lock_;
126 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); 127 DISALLOW_COPY_AND_ASSIGN(AutoUnlock);
127 }; 128 };
128 129
129 } // namespace base 130 } // namespace base
130 131
131 #endif // BASE_SYNCHRONIZATION_LOCK_H_ 132 #endif // BASE_SYNCHRONIZATION_LOCK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698