| Index: webrtc/system_wrappers/source/critical_section.cc
|
| diff --git a/webrtc/system_wrappers/source/critical_section.cc b/webrtc/system_wrappers/source/critical_section.cc
|
| index c5865887cd07897a068032e666a5c333124e775e..a8a5a6d40b7bdff06b42585884463d0f109c825c 100644
|
| --- a/webrtc/system_wrappers/source/critical_section.cc
|
| +++ b/webrtc/system_wrappers/source/critical_section.cc
|
| @@ -8,21 +8,53 @@
|
| * be found in the AUTHORS file in the root of the source tree.
|
| */
|
|
|
| -#if defined(_WIN32)
|
| -#include <windows.h>
|
| -#include "webrtc/system_wrappers/source/critical_section_win.h"
|
| -#else
|
| -#include "webrtc/system_wrappers/source/critical_section_posix.h"
|
| -#endif
|
| +#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
|
|
| namespace webrtc {
|
|
|
| CriticalSectionWrapper* CriticalSectionWrapper::CreateCriticalSection() {
|
| -#ifdef _WIN32
|
| - return new CriticalSectionWindows();
|
| + return new CriticalSectionWrapper();
|
| +}
|
| +
|
| +#if defined (WEBRTC_WIN)
|
| +
|
| +CriticalSectionWrapper::CriticalSectionWrapper() {
|
| + InitializeCriticalSection(&crit_);
|
| +}
|
| +
|
| +CriticalSectionWrapper::~CriticalSectionWrapper() {
|
| + DeleteCriticalSection(&crit_);
|
| +}
|
| +
|
| +void CriticalSectionWrapper::Enter() {
|
| + EnterCriticalSection(&crit_);
|
| +}
|
| +
|
| +void CriticalSectionWrapper::Leave() {
|
| + LeaveCriticalSection(&crit_);
|
| +}
|
| +
|
| #else
|
| - return new CriticalSectionPosix();
|
| -#endif
|
| +
|
| +CriticalSectionWrapper::CriticalSectionWrapper() {
|
| + pthread_mutexattr_t attr;
|
| + pthread_mutexattr_init(&attr);
|
| + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
| + pthread_mutex_init(&mutex_, &attr);
|
| }
|
|
|
| +CriticalSectionWrapper::~CriticalSectionWrapper() {
|
| + pthread_mutex_destroy(&mutex_);
|
| +}
|
| +
|
| +void CriticalSectionWrapper::Enter() {
|
| + pthread_mutex_lock(&mutex_);
|
| +}
|
| +
|
| +void CriticalSectionWrapper::Leave() {
|
| + pthread_mutex_unlock(&mutex_);
|
| +}
|
| +
|
| +#endif
|
| +
|
| } // namespace webrtc
|
|
|