| 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_IMPL_H_ | 5 #ifndef BASE_SYNCHRONIZATION_LOCK_IMPL_H_ |
| 6 #define BASE_SYNCHRONIZATION_LOCK_IMPL_H_ | 6 #define BASE_SYNCHRONIZATION_LOCK_IMPL_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_POSIX) |
| 11 #include <windows.h> | |
| 12 #elif defined(OS_POSIX) | |
| 13 #include <pthread.h> | 11 #include <pthread.h> |
| 14 #endif | 12 #endif |
| 15 | 13 |
| 16 #include "base/base_export.h" | 14 #include "base/base_export.h" |
| 17 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 18 | 16 |
| 19 namespace base { | 17 namespace base { |
| 20 namespace internal { | 18 namespace internal { |
| 21 | 19 |
| 22 // This class implements the underlying platform-specific spin-lock mechanism | 20 // This class implements the underlying platform-specific spin-lock mechanism |
| 23 // used for the Lock class. Most users should not use LockImpl directly, but | 21 // used for the Lock class. Most users should not use LockImpl directly, but |
| 24 // should instead use Lock. | 22 // should instead use Lock. |
| 25 class BASE_EXPORT LockImpl { | 23 class BASE_EXPORT LockImpl { |
| 26 public: | 24 public: |
| 27 #if defined(OS_WIN) | 25 #if defined(OS_POSIX) |
| 28 typedef CRITICAL_SECTION NativeHandle; | |
| 29 #elif defined(OS_POSIX) | |
| 30 typedef pthread_mutex_t NativeHandle; | 26 typedef pthread_mutex_t NativeHandle; |
| 31 #endif | 27 #endif |
| 32 | 28 |
| 33 LockImpl(); | 29 LockImpl(); |
| 34 ~LockImpl(); | 30 ~LockImpl(); |
| 35 | 31 |
| 36 // If the lock is not held, take it and return true. If the lock is already | 32 // If the lock is not held, take it and return true. If the lock is already |
| 37 // held by something else, immediately return false. | 33 // held by something else, immediately return false. |
| 38 bool Try(); | 34 bool Try(); |
| 39 | 35 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 52 private: | 48 private: |
| 53 NativeHandle native_handle_; | 49 NativeHandle native_handle_; |
| 54 | 50 |
| 55 DISALLOW_COPY_AND_ASSIGN(LockImpl); | 51 DISALLOW_COPY_AND_ASSIGN(LockImpl); |
| 56 }; | 52 }; |
| 57 | 53 |
| 58 } // namespace internal | 54 } // namespace internal |
| 59 } // namespace base | 55 } // namespace base |
| 60 | 56 |
| 61 #endif // BASE_SYNCHRONIZATION_LOCK_IMPL_H_ | 57 #endif // BASE_SYNCHRONIZATION_LOCK_IMPL_H_ |
| OLD | NEW |