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 |