OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_BASE_CRITICALSECTION_H_ | 11 #ifndef WEBRTC_BASE_CRITICALSECTION_H_ |
12 #define WEBRTC_BASE_CRITICALSECTION_H_ | 12 #define WEBRTC_BASE_CRITICALSECTION_H_ |
13 | 13 |
14 #include "webrtc/base/atomicops.h" | 14 #include "webrtc/base/atomicops.h" |
15 #include "webrtc/base/checks.h" | |
16 #include "webrtc/base/constructormagic.h" | 15 #include "webrtc/base/constructormagic.h" |
17 #include "webrtc/base/thread_annotations.h" | 16 #include "webrtc/base/thread_annotations.h" |
18 #include "webrtc/base/platform_thread_types.h" | 17 #include "webrtc/base/platform_thread_types.h" |
19 | 18 |
20 #if defined(WEBRTC_WIN) | 19 #if defined(WEBRTC_WIN) |
21 // Include winsock2.h before including <windows.h> to maintain consistency with | 20 // Include winsock2.h before including <windows.h> to maintain consistency with |
22 // win32.h. We can't include win32.h directly here since it pulls in | 21 // win32.h. We can't include win32.h directly here since it pulls in |
23 // headers such as basictypes.h which causes problems in Chromium where webrtc | 22 // headers such as basictypes.h which causes problems in Chromium where webrtc |
24 // exists as two separate projects, webrtc and libjingle. | 23 // exists as two separate projects, webrtc and libjingle. |
25 #include <winsock2.h> | 24 #include <winsock2.h> |
26 #include <windows.h> | 25 #include <windows.h> |
27 #include <sal.h> // must come after windows headers. | 26 #include <sal.h> // must come after windows headers. |
28 #endif // defined(WEBRTC_WIN) | 27 #endif // defined(WEBRTC_WIN) |
29 | 28 |
30 #if defined(WEBRTC_POSIX) | 29 #if defined(WEBRTC_POSIX) |
31 #include <pthread.h> | 30 #include <pthread.h> |
32 #endif | 31 #endif |
33 | 32 |
34 // See notes in the 'Performance' unit test for the effects of this flag. | 33 // See notes in the 'Performance' unit test for the effects of this flag. |
35 #define USE_NATIVE_MUTEX_ON_MAC 0 | 34 #define USE_NATIVE_MUTEX_ON_MAC 0 |
36 | 35 |
37 #if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC | 36 #if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC |
38 #include <dispatch/dispatch.h> | 37 #include <dispatch/dispatch.h> |
39 #endif | 38 #endif |
40 | 39 |
41 #define CS_DEBUG_CHECKS RTC_DCHECK_IS_ON | 40 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
| 41 #define CS_DEBUG_CHECKS 1 |
| 42 #else |
| 43 #define CS_DEBUG_CHECKS 0 |
| 44 #endif |
42 | 45 |
43 #if CS_DEBUG_CHECKS | 46 #if CS_DEBUG_CHECKS |
44 #define CS_DEBUG_CODE(x) x | 47 #define CS_DEBUG_CODE(x) x |
45 #else // !CS_DEBUG_CHECKS | 48 #else // !CS_DEBUG_CHECKS |
46 #define CS_DEBUG_CODE(x) | 49 #define CS_DEBUG_CODE(x) |
47 #endif // !CS_DEBUG_CHECKS | 50 #endif // !CS_DEBUG_CHECKS |
48 | 51 |
49 namespace rtc { | 52 namespace rtc { |
50 | 53 |
51 // Locking methods (Enter, TryEnter, Leave)are const to permit protecting | 54 // Locking methods (Enter, TryEnter, Leave)are const to permit protecting |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 explicit GlobalLockScope(GlobalLockPod* lock) EXCLUSIVE_LOCK_FUNCTION(lock); | 145 explicit GlobalLockScope(GlobalLockPod* lock) EXCLUSIVE_LOCK_FUNCTION(lock); |
143 ~GlobalLockScope() UNLOCK_FUNCTION(); | 146 ~GlobalLockScope() UNLOCK_FUNCTION(); |
144 private: | 147 private: |
145 GlobalLockPod* const lock_; | 148 GlobalLockPod* const lock_; |
146 RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope); | 149 RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope); |
147 }; | 150 }; |
148 | 151 |
149 } // namespace rtc | 152 } // namespace rtc |
150 | 153 |
151 #endif // WEBRTC_BASE_CRITICALSECTION_H_ | 154 #endif // WEBRTC_BASE_CRITICALSECTION_H_ |
OLD | NEW |