aboutsummaryrefslogtreecommitdiff
path: root/rtc_base
diff options
context:
space:
mode:
authorMarkus Handell <handellm@webrtc.org>2020-07-15 13:23:30 +0200
committerCommit Bot <commit-bot@chromium.org>2020-07-15 20:45:13 +0000
commit4c7bb27a10e575730860494db14f2d1559396f97 (patch)
tree790ee8d721f6f650d9c2e0f48f62a15b4068a394 /rtc_base
parente7e17d3e4c8dd92edc11d3c50d44ae5f39c9ebb2 (diff)
downloadwebrtc-4c7bb27a10e575730860494db14f2d1559396f97.tar.gz
Remove rtc::GlobalLock.
This change migrates a last stray consumer of GlobalLock (SrtpSession) and removes all traces of GlobalLock/GlobalLockScope from WebRTC. Bug: webrtc:11567 Change-Id: I28059f2a10075815a4bdee8c357b9d3b6e50f18b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179361 Commit-Queue: Tommi <tommi@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31736}
Diffstat (limited to 'rtc_base')
-rw-r--r--rtc_base/critical_section.cc19
-rw-r--r--rtc_base/critical_section.h23
-rw-r--r--rtc_base/critical_section_unittest.cc19
3 files changed, 0 insertions, 61 deletions
diff --git a/rtc_base/critical_section.cc b/rtc_base/critical_section.cc
index c6b17ff1b2..1f68299aab 100644
--- a/rtc_base/critical_section.cc
+++ b/rtc_base/critical_section.cc
@@ -217,23 +217,4 @@ CritScope::~CritScope() {
cs_->Leave();
}
-void GlobalLock::Lock() {
- while (AtomicOps::CompareAndSwap(&lock_acquired_, 0, 1)) {
- webrtc::YieldCurrentThread();
- }
-}
-
-void GlobalLock::Unlock() {
- int old_value = AtomicOps::CompareAndSwap(&lock_acquired_, 1, 0);
- RTC_DCHECK_EQ(1, old_value) << "Unlock called without calling Lock first";
-}
-
-GlobalLockScope::GlobalLockScope(GlobalLock* lock) : lock_(lock) {
- lock_->Lock();
-}
-
-GlobalLockScope::~GlobalLockScope() {
- lock_->Unlock();
-}
-
} // namespace rtc
diff --git a/rtc_base/critical_section.h b/rtc_base/critical_section.h
index cf10463bdf..af16861447 100644
--- a/rtc_base/critical_section.h
+++ b/rtc_base/critical_section.h
@@ -95,29 +95,6 @@ class RTC_SCOPED_LOCKABLE CritScope {
RTC_DISALLOW_COPY_AND_ASSIGN(CritScope);
};
-// A lock used to protect global variables. Do NOT use for other purposes.
-class RTC_LOCKABLE GlobalLock {
- public:
- constexpr GlobalLock() : lock_acquired_(0) {}
-
- void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION();
- void Unlock() RTC_UNLOCK_FUNCTION();
-
- private:
- volatile int lock_acquired_;
-};
-
-// GlobalLockScope, for serializing execution through a scope.
-class RTC_SCOPED_LOCKABLE GlobalLockScope {
- public:
- explicit GlobalLockScope(GlobalLock* lock) RTC_EXCLUSIVE_LOCK_FUNCTION(lock);
- ~GlobalLockScope() RTC_UNLOCK_FUNCTION();
-
- private:
- GlobalLock* const lock_;
- RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope);
-};
-
} // namespace rtc
#endif // RTC_BASE_CRITICAL_SECTION_H_
diff --git a/rtc_base/critical_section_unittest.cc b/rtc_base/critical_section_unittest.cc
index 16aefd2740..52d0a8f865 100644
--- a/rtc_base/critical_section_unittest.cc
+++ b/rtc_base/critical_section_unittest.cc
@@ -282,25 +282,6 @@ TEST(AtomicOpsTest, CompareAndSwap) {
EXPECT_EQ(1, runner.shared_value());
}
-TEST(GlobalLockTest, CanHaveStaticStorageDuration) {
- static_assert(std::is_trivially_destructible<GlobalLock>::value, "");
- ABSL_CONST_INIT static GlobalLock global_lock;
- global_lock.Lock();
- global_lock.Unlock();
-}
-
-TEST(GlobalLockTest, Basic) {
- // Create and start lots of threads.
- LockRunner<GlobalLock> runner;
- std::vector<std::unique_ptr<Thread>> threads;
- StartThreads(&threads, &runner);
- runner.SetExpectedThreadCount(kNumThreads);
-
- // Release the hounds!
- EXPECT_TRUE(runner.Run());
- EXPECT_EQ(0, runner.shared_value());
-}
-
TEST(CriticalSectionTest, Basic) {
// Create and start lots of threads.
LockRunner<CriticalSectionLock> runner;