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 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // everywhere. | 54 // everywhere. |
55 class LOCKABLE CriticalSection { | 55 class LOCKABLE CriticalSection { |
56 public: | 56 public: |
57 CriticalSection(); | 57 CriticalSection(); |
58 ~CriticalSection(); | 58 ~CriticalSection(); |
59 | 59 |
60 void Enter() const EXCLUSIVE_LOCK_FUNCTION(); | 60 void Enter() const EXCLUSIVE_LOCK_FUNCTION(); |
61 bool TryEnter() const EXCLUSIVE_TRYLOCK_FUNCTION(true); | 61 bool TryEnter() const EXCLUSIVE_TRYLOCK_FUNCTION(true); |
62 void Leave() const UNLOCK_FUNCTION(); | 62 void Leave() const UNLOCK_FUNCTION(); |
63 | 63 |
| 64 private: |
64 // Use only for RTC_DCHECKing. | 65 // Use only for RTC_DCHECKing. |
65 bool CurrentThreadIsOwner() const; | 66 bool CurrentThreadIsOwner() const; |
66 | 67 |
67 private: | |
68 #if defined(WEBRTC_WIN) | 68 #if defined(WEBRTC_WIN) |
69 mutable CRITICAL_SECTION crit_; | 69 mutable CRITICAL_SECTION crit_; |
70 #elif defined(WEBRTC_POSIX) | 70 #elif defined(WEBRTC_POSIX) |
71 #if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC | 71 #if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC |
72 // Number of times the lock has been locked + number of threads waiting. | 72 // Number of times the lock has been locked + number of threads waiting. |
73 // TODO(tommi): We could use this number and subtract the recursion count | 73 // TODO(tommi): We could use this number and subtract the recursion count |
74 // to find places where we have multiple threads contending on the same lock. | 74 // to find places where we have multiple threads contending on the same lock. |
75 mutable volatile int lock_queue_; | 75 mutable volatile int lock_queue_; |
76 // |recursion_| represents the recursion count + 1 for the thread that owns | 76 // |recursion_| represents the recursion count + 1 for the thread that owns |
77 // the lock. Only modified by the thread that owns the lock. | 77 // the lock. Only modified by the thread that owns the lock. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 explicit GlobalLockScope(GlobalLockPod* lock) EXCLUSIVE_LOCK_FUNCTION(lock); | 143 explicit GlobalLockScope(GlobalLockPod* lock) EXCLUSIVE_LOCK_FUNCTION(lock); |
144 ~GlobalLockScope() UNLOCK_FUNCTION(); | 144 ~GlobalLockScope() UNLOCK_FUNCTION(); |
145 private: | 145 private: |
146 GlobalLockPod* const lock_; | 146 GlobalLockPod* const lock_; |
147 RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope); | 147 RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope); |
148 }; | 148 }; |
149 | 149 |
150 } // namespace rtc | 150 } // namespace rtc |
151 | 151 |
152 #endif // WEBRTC_BASE_CRITICALSECTION_H_ | 152 #endif // WEBRTC_BASE_CRITICALSECTION_H_ |
OLD | NEW |