Chromium Code Reviews

Side by Side Diff: webrtc/system_wrappers/include/critical_section_wrapper.h

Issue 1601523009: Remove ConditionVariableWrapper. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Move include inside guard Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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 28 matching lines...)
39 // Tries to grab lock, beginning of a critical section. Will wait for the 39 // Tries to grab lock, beginning of a critical section. Will wait for the
40 // lock to become available if the grab failed. 40 // lock to become available if the grab failed.
41 void Enter() EXCLUSIVE_LOCK_FUNCTION(); 41 void Enter() EXCLUSIVE_LOCK_FUNCTION();
42 42
43 // Returns a grabbed lock, end of critical section. 43 // Returns a grabbed lock, end of critical section.
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
50 // TODO(tommi): Remove friendness.
51 friend class ConditionVariableEventWin;
52 friend class ConditionVariableNativeWin;
53 #else 49 #else
54 pthread_mutex_t mutex_; 50 pthread_mutex_t mutex_;
55 #endif 51 #endif
56 }; 52 };
57 53
58 // RAII extension of the critical section. Prevents Enter/Leave mismatches and 54 // RAII extension of the critical section. Prevents Enter/Leave mismatches and
59 // provides more compact critical section syntax. 55 // provides more compact critical section syntax.
60 class SCOPED_LOCKABLE CriticalSectionScoped { 56 class SCOPED_LOCKABLE CriticalSectionScoped {
61 public: 57 public:
62 explicit CriticalSectionScoped(CriticalSectionWrapper* critsec) 58 explicit CriticalSectionScoped(CriticalSectionWrapper* critsec)
63 EXCLUSIVE_LOCK_FUNCTION(critsec) 59 EXCLUSIVE_LOCK_FUNCTION(critsec)
64 : ptr_crit_sec_(critsec) { 60 : ptr_crit_sec_(critsec) {
65 ptr_crit_sec_->Enter(); 61 ptr_crit_sec_->Enter();
66 } 62 }
67 63
68 ~CriticalSectionScoped() UNLOCK_FUNCTION() { ptr_crit_sec_->Leave(); } 64 ~CriticalSectionScoped() UNLOCK_FUNCTION() { ptr_crit_sec_->Leave(); }
69 65
70 private: 66 private:
71 CriticalSectionWrapper* ptr_crit_sec_; 67 CriticalSectionWrapper* ptr_crit_sec_;
72 }; 68 };
73 69
74 } // namespace webrtc 70 } // namespace webrtc
75 71
76 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_ 72 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_
OLDNEW
« no previous file with comments | « webrtc/system_wrappers/include/condition_variable_wrapper.h ('k') | webrtc/system_wrappers/source/condition_variable.cc » ('j') | no next file with comments »

Powered by Google App Engine