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

Unified Diff: webrtc/system_wrappers/include/critical_section_wrapper.h

Issue 1601743004: Make CriticalSectionWrapper non-virtual (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix windows build 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/include/critical_section_wrapper.h
diff --git a/webrtc/system_wrappers/include/critical_section_wrapper.h b/webrtc/system_wrappers/include/critical_section_wrapper.h
index 7dd217e40d8266e8ad42dfd61a0c1d8cef982cd6..ed97824b436bee7948cf8977d459ef217bbdd5dc 100644
--- a/webrtc/system_wrappers/include/critical_section_wrapper.h
+++ b/webrtc/system_wrappers/include/critical_section_wrapper.h
@@ -14,23 +14,45 @@
// If the critical section is heavily contended it may be beneficial to use
// read/write locks instead.
+#if defined (WEBRTC_WIN)
+#include <windows.h>
+#else
+#include <pthread.h>
+#endif
+
#include "webrtc/base/thread_annotations.h"
#include "webrtc/common_types.h"
namespace webrtc {
+
class LOCKABLE CriticalSectionWrapper {
public:
// Factory method, constructor disabled
+ // TODO(tommi): Remove this method.
pbos-webrtc 2016/01/19 13:04:41 The real TODO should imo be to nuke this file and
tommi 2016/01/19 13:57:15 Right... I'll see if we can get rid of the Conditi
static CriticalSectionWrapper* CreateCriticalSection();
- virtual ~CriticalSectionWrapper() {}
+ CriticalSectionWrapper();
+ ~CriticalSectionWrapper();
// Tries to grab lock, beginning of a critical section. Will wait for the
// lock to become available if the grab failed.
- virtual void Enter() EXCLUSIVE_LOCK_FUNCTION() = 0;
+ void Enter() EXCLUSIVE_LOCK_FUNCTION();
// Returns a grabbed lock, end of critical section.
- virtual void Leave() UNLOCK_FUNCTION() = 0;
+ void Leave() UNLOCK_FUNCTION();
+
+private:
+#if defined (WEBRTC_WIN)
+ CRITICAL_SECTION crit_;
+
+ // TODO(tommi): Remove friendness.
+ friend class ConditionVariableEventWin;
+ friend class ConditionVariableNativeWin;
+#else
+ // TODO(tommi): Remove friendness.
+ pthread_mutex_t mutex_;
+ friend class ConditionVariablePosix;
+#endif
};
// RAII extension of the critical section. Prevents Enter/Leave mismatches and

Powered by Google App Engine
This is Rietveld 408576698