Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

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

Issue 2790533002: Remove ALL usage of CriticalSectionWrapper. (Closed)
Patch Set: remove winXP rw_lock include Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_
12 #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_
13
14 #include "webrtc/base/criticalsection.h"
15 #include "webrtc/base/thread_annotations.h"
16 #include "webrtc/common_types.h"
17
18 namespace webrtc {
19
20 class LOCKABLE CriticalSectionWrapper {
21 public:
22 // Legacy factory method, being deprecated. Please use the constructor.
23 // TODO(tommi): Remove the CriticalSectionWrapper class and move users over
24 // to using rtc::CriticalSection.
25 static CriticalSectionWrapper* CreateCriticalSection() {
26 return new CriticalSectionWrapper();
27 }
28
29 CriticalSectionWrapper() {}
30 ~CriticalSectionWrapper() {}
31
32 // Tries to grab lock, beginning of a critical section. Will wait for the
33 // lock to become available if the grab failed.
34 void Enter() EXCLUSIVE_LOCK_FUNCTION() { lock_.Enter(); }
35
36 // Returns a grabbed lock, end of critical section.
37 void Leave() UNLOCK_FUNCTION() { lock_.Leave(); }
38
39 private:
40 rtc::CriticalSection lock_;
41 };
42
43 // RAII extension of the critical section. Prevents Enter/Leave mismatches and
44 // provides more compact critical section syntax.
45 class SCOPED_LOCKABLE CriticalSectionScoped {
46 public:
47 explicit CriticalSectionScoped(CriticalSectionWrapper* critsec)
48 EXCLUSIVE_LOCK_FUNCTION(critsec)
49 : ptr_crit_sec_(critsec) {
50 ptr_crit_sec_->Enter();
51 }
52
53 ~CriticalSectionScoped() UNLOCK_FUNCTION() { ptr_crit_sec_->Leave(); }
54
55 private:
56 CriticalSectionWrapper* ptr_crit_sec_;
57 };
58
59 } // namespace webrtc
60
61 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_
OLDNEW
« no previous file with comments | « webrtc/system_wrappers/BUILD.gn ('k') | webrtc/system_wrappers/source/condition_variable_event_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698