OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 void Leave() UNLOCK_FUNCTION(); | 44 void Leave() UNLOCK_FUNCTION(); |
45 | 45 |
46 private: | 46 private: |
47 #if defined (WEBRTC_WIN) | 47 #if defined (WEBRTC_WIN) |
48 CRITICAL_SECTION crit_; | 48 CRITICAL_SECTION crit_; |
49 | 49 |
50 // TODO(tommi): Remove friendness. | 50 // TODO(tommi): Remove friendness. |
51 friend class ConditionVariableEventWin; | 51 friend class ConditionVariableEventWin; |
52 friend class ConditionVariableNativeWin; | 52 friend class ConditionVariableNativeWin; |
53 #else | 53 #else |
54 // TODO(tommi): Remove friendness. | |
55 pthread_mutex_t mutex_; | 54 pthread_mutex_t mutex_; |
56 friend class ConditionVariablePosix; | |
57 #endif | 55 #endif |
58 }; | 56 }; |
59 | 57 |
60 // RAII extension of the critical section. Prevents Enter/Leave mismatches and | 58 // RAII extension of the critical section. Prevents Enter/Leave mismatches and |
61 // provides more compact critical section syntax. | 59 // provides more compact critical section syntax. |
62 class SCOPED_LOCKABLE CriticalSectionScoped { | 60 class SCOPED_LOCKABLE CriticalSectionScoped { |
63 public: | 61 public: |
64 explicit CriticalSectionScoped(CriticalSectionWrapper* critsec) | 62 explicit CriticalSectionScoped(CriticalSectionWrapper* critsec) |
65 EXCLUSIVE_LOCK_FUNCTION(critsec) | 63 EXCLUSIVE_LOCK_FUNCTION(critsec) |
66 : ptr_crit_sec_(critsec) { | 64 : ptr_crit_sec_(critsec) { |
67 ptr_crit_sec_->Enter(); | 65 ptr_crit_sec_->Enter(); |
68 } | 66 } |
69 | 67 |
70 ~CriticalSectionScoped() UNLOCK_FUNCTION() { ptr_crit_sec_->Leave(); } | 68 ~CriticalSectionScoped() UNLOCK_FUNCTION() { ptr_crit_sec_->Leave(); } |
71 | 69 |
72 private: | 70 private: |
73 CriticalSectionWrapper* ptr_crit_sec_; | 71 CriticalSectionWrapper* ptr_crit_sec_; |
74 }; | 72 }; |
75 | 73 |
76 } // namespace webrtc | 74 } // namespace webrtc |
77 | 75 |
78 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_ | 76 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_ |
OLD | NEW |