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

Side by Side Diff: webrtc/system_wrappers/source/critical_section.cc

Issue 1601743004: Make CriticalSectionWrapper non-virtual (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Improve comment Created 4 years, 11 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
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
11 #if defined(_WIN32) 11 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
12 #include <windows.h>
13 #include "webrtc/system_wrappers/source/critical_section_win.h"
14 #else
15 #include "webrtc/system_wrappers/source/critical_section_posix.h"
16 #endif
17 12
18 namespace webrtc { 13 namespace webrtc {
19 14
20 CriticalSectionWrapper* CriticalSectionWrapper::CreateCriticalSection() { 15 CriticalSectionWrapper* CriticalSectionWrapper::CreateCriticalSection() {
21 #ifdef _WIN32 16 return new CriticalSectionWrapper();
22 return new CriticalSectionWindows();
23 #else
24 return new CriticalSectionPosix();
25 #endif
26 } 17 }
27 18
19 #if defined (WEBRTC_WIN)
20
21 CriticalSectionWrapper::CriticalSectionWrapper() {
22 InitializeCriticalSection(&crit_);
23 }
24
25 CriticalSectionWrapper::~CriticalSectionWrapper() {
26 DeleteCriticalSection(&crit_);
27 }
28
29 void CriticalSectionWrapper::Enter() {
30 EnterCriticalSection(&crit_);
31 }
32
33 void CriticalSectionWrapper::Leave() {
34 LeaveCriticalSection(&crit_);
35 }
36
37 #else
38
39 CriticalSectionWrapper::CriticalSectionWrapper() {
40 pthread_mutexattr_t attr;
41 pthread_mutexattr_init(&attr);
42 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
43 pthread_mutex_init(&mutex_, &attr);
44 }
45
46 CriticalSectionWrapper::~CriticalSectionWrapper() {
47 pthread_mutex_destroy(&mutex_);
48 }
49
50 void CriticalSectionWrapper::Enter() {
51 pthread_mutex_lock(&mutex_);
52 }
53
54 void CriticalSectionWrapper::Leave() {
55 pthread_mutex_unlock(&mutex_);
56 }
57
58 #endif
59
28 } // namespace webrtc 60 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/system_wrappers/source/condition_variable_posix.cc ('k') | webrtc/system_wrappers/source/critical_section_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698