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

Unified 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 side-by-side diff with in-line comments
Download patch
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
« 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