Chromium Code Reviews| Index: webrtc/base/criticalsection.h |
| diff --git a/webrtc/base/criticalsection.h b/webrtc/base/criticalsection.h |
| index 5b3eaf56840cd1698701ac1669ccca9b3763c0b4..d4299a8c77f4f5425dad59b03444ada79da8e8e7 100644 |
| --- a/webrtc/base/criticalsection.h |
| +++ b/webrtc/base/criticalsection.h |
| @@ -46,9 +46,9 @@ class LOCKABLE CriticalSection { |
| CriticalSection(); |
| ~CriticalSection(); |
| - void Enter() EXCLUSIVE_LOCK_FUNCTION(); |
| - bool TryEnter() EXCLUSIVE_TRYLOCK_FUNCTION(true); |
| - void Leave() UNLOCK_FUNCTION(); |
| + void Enter() const EXCLUSIVE_LOCK_FUNCTION(); |
|
tommi
2016/01/21 15:39:36
can you add a class-level comment that explains wh
pbos-webrtc
2016/01/21 15:41:32
Done.
|
| + bool TryEnter() const EXCLUSIVE_TRYLOCK_FUNCTION(true); |
| + void Leave() const UNLOCK_FUNCTION(); |
| // Use only for RTC_DCHECKing. |
| bool CurrentThreadIsOwner() const; |
| @@ -57,21 +57,21 @@ class LOCKABLE CriticalSection { |
| private: |
| #if defined(WEBRTC_WIN) |
| - CRITICAL_SECTION crit_; |
| + mutable CRITICAL_SECTION crit_; |
| #elif defined(WEBRTC_POSIX) |
| - pthread_mutex_t mutex_; |
| - CS_DEBUG_CODE(pthread_t thread_); |
| - CS_DEBUG_CODE(int recursion_count_); |
| + mutable pthread_mutex_t mutex_; |
| + CS_DEBUG_CODE(mutable pthread_t thread_); |
| + CS_DEBUG_CODE(mutable int recursion_count_); |
| #endif |
| }; |
| // CritScope, for serializing execution through a scope. |
| class SCOPED_LOCKABLE CritScope { |
| public: |
| - explicit CritScope(CriticalSection* cs) EXCLUSIVE_LOCK_FUNCTION(cs); |
| + explicit CritScope(const CriticalSection* cs) EXCLUSIVE_LOCK_FUNCTION(cs); |
| ~CritScope() UNLOCK_FUNCTION(); |
| private: |
| - CriticalSection* const cs_; |
| + const CriticalSection* const cs_; |
| RTC_DISALLOW_COPY_AND_ASSIGN(CritScope); |
| }; |
| @@ -84,7 +84,7 @@ class SCOPED_LOCKABLE CritScope { |
| // lock was taken. If you're not calling locked(), you're doing it wrong! |
| class TryCritScope { |
| public: |
| - explicit TryCritScope(CriticalSection* cs); |
| + explicit TryCritScope(const CriticalSection* cs); |
| ~TryCritScope(); |
| #if defined(WEBRTC_WIN) |
| _Check_return_ bool locked() const; |
| @@ -92,7 +92,7 @@ class TryCritScope { |
| bool locked() const __attribute__ ((__warn_unused_result__)); |
| #endif |
| private: |
| - CriticalSection* const cs_; |
| + const CriticalSection* const cs_; |
| const bool locked_; |
| CS_DEBUG_CODE(mutable bool lock_was_called_); |
| RTC_DISALLOW_COPY_AND_ASSIGN(TryCritScope); |