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

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: 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
« no previous file with comments | « webrtc/system_wrappers/BUILD.gn ('k') | webrtc/system_wrappers/source/condition_variable_event_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b9e05a35c25d6f25c9c12b2cea346a6958045911 100644
--- a/webrtc/system_wrappers/include/critical_section_wrapper.h
+++ b/webrtc/system_wrappers/include/critical_section_wrapper.h
@@ -14,23 +14,47 @@
// 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
+ // Legacy factory method, being deprecated. Please use the constructor.
+ // TODO(tommi): Remove the CriticalSectionWrapper class and move users over
+ // to using rtc::CriticalSection. Before we can do that though, we need to
+ // fix the problem with the ConditionVariable* classes (see below).
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
« no previous file with comments | « webrtc/system_wrappers/BUILD.gn ('k') | webrtc/system_wrappers/source/condition_variable_event_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698