From 2644a703cc6ee4b3893a1f1f657f58473455cce5 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Tue, 25 Jun 2019 14:24:04 +0200 Subject: [PATCH] Delete rtc::TryCritScope as unused Bug: None Change-Id: I9288f26d22835fc4e8ee7e5da5acfa4b4b527d8a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143163 Commit-Queue: Danil Chapovalov Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#28389} --- rtc_base/critical_section.cc | 17 ----------------- rtc_base/critical_section.h | 25 ------------------------- 2 files changed, 42 deletions(-) diff --git a/rtc_base/critical_section.cc b/rtc_base/critical_section.cc index 2100fe9fb4..db6831f453 100644 --- a/rtc_base/critical_section.cc +++ b/rtc_base/critical_section.cc @@ -210,23 +210,6 @@ CritScope::~CritScope() { cs_->Leave(); } -TryCritScope::TryCritScope(const CriticalSection* cs) - : cs_(cs), locked_(cs->TryEnter()) { - CS_DEBUG_CODE(lock_was_called_ = false); - RTC_UNUSED(lock_was_called_); -} - -TryCritScope::~TryCritScope() { - CS_DEBUG_CODE(RTC_DCHECK(lock_was_called_)); - if (locked_) - cs_->Leave(); -} - -bool TryCritScope::locked() const { - CS_DEBUG_CODE(lock_was_called_ = true); - return locked_; -} - void GlobalLockPod::Lock() { #if !defined(WEBRTC_WIN) && (!defined(WEBRTC_MAC) || USE_NATIVE_MUTEX_ON_MAC) const struct timespec ts_null = {0}; diff --git a/rtc_base/critical_section.h b/rtc_base/critical_section.h index d575b973a5..ddb701f6ab 100644 --- a/rtc_base/critical_section.h +++ b/rtc_base/critical_section.h @@ -102,31 +102,6 @@ class RTC_SCOPED_LOCKABLE CritScope { RTC_DISALLOW_COPY_AND_ASSIGN(CritScope); }; -// Tries to lock a critical section on construction via -// CriticalSection::TryEnter, and unlocks on destruction if the -// lock was taken. Never blocks. -// -// IMPORTANT: Unlike CritScope, the lock may not be owned by this thread in -// subsequent code. Users *must* check locked() to determine if the -// lock was taken. If you're not calling locked(), you're doing it wrong! -class TryCritScope { - public: - explicit TryCritScope(const CriticalSection* cs); - ~TryCritScope(); -#if defined(WEBRTC_WIN) - _Check_return_ bool locked() const; -#elif defined(WEBRTC_POSIX) - bool locked() const __attribute__((__warn_unused_result__)); -#else // !defined(WEBRTC_WIN) && !defined(WEBRTC_POSIX) -#error Unsupported platform. -#endif - private: - const CriticalSection* const cs_; - const bool locked_; - mutable bool lock_was_called_; // Only used by RTC_DCHECKs. - RTC_DISALLOW_COPY_AND_ASSIGN(TryCritScope); -}; - // A POD lock used to protect global variables. Do NOT use for other purposes. // No custom constructor or private data member should be added. class RTC_LOCKABLE GlobalLockPod {