| OLD | NEW |
| (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 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | |
| 12 | |
| 13 namespace webrtc { | |
| 14 | |
| 15 CriticalSectionWrapper* CriticalSectionWrapper::CreateCriticalSection() { | |
| 16 return new CriticalSectionWrapper(); | |
| 17 } | |
| 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 | |
| 60 } // namespace webrtc | |
| OLD | NEW |