| OLD | NEW |
| 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/base_export.h" |
| 10 #include "base/synchronization/lock_impl.h" | 10 #include "base/synchronization/lock_impl.h" |
| 11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 | 14 |
| 15 // 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 |
| 16 // 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 |
| 17 // AssertAcquired() method. | 17 // AssertAcquired() method. |
| 18 class BASE_API Lock { | 18 class BASE_EXPORT Lock { |
| 19 public: | 19 public: |
| 20 #if defined(NDEBUG) // Optimized wrapper implementation | 20 #if defined(NDEBUG) // Optimized wrapper implementation |
| 21 Lock() : lock_() {} | 21 Lock() : lock_() {} |
| 22 ~Lock() {} | 22 ~Lock() {} |
| 23 void Acquire() { lock_.Lock(); } | 23 void Acquire() { lock_.Lock(); } |
| 24 void Release() { lock_.Unlock(); } | 24 void Release() { lock_.Unlock(); } |
| 25 | 25 |
| 26 // 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 |
| 27 // 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 |
| 28 // 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 Loading... |
| 123 } | 123 } |
| 124 | 124 |
| 125 private: | 125 private: |
| 126 Lock& lock_; | 126 Lock& lock_; |
| 127 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); | 127 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 } // namespace base | 130 } // namespace base |
| 131 | 131 |
| 132 #endif // BASE_SYNCHRONIZATION_LOCK_H_ | 132 #endif // BASE_SYNCHRONIZATION_LOCK_H_ |
| OLD | NEW |