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

Side by Side Diff: webrtc/rtc_base/criticalsection.cc

Issue 3006133002: Update thread annotiation macros in rtc_base to use RTC_ prefix (Closed)
Patch Set: Rebase Created 3 years, 3 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 unified diff | Download patch
« no previous file with comments | « webrtc/rtc_base/criticalsection.h ('k') | webrtc/rtc_base/criticalsection_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 # if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC 49 # if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
50 dispatch_release(semaphore_); 50 dispatch_release(semaphore_);
51 # else 51 # else
52 pthread_mutex_destroy(&mutex_); 52 pthread_mutex_destroy(&mutex_);
53 # endif 53 # endif
54 #else 54 #else
55 # error Unsupported platform. 55 # error Unsupported platform.
56 #endif 56 #endif
57 } 57 }
58 58
59 void CriticalSection::Enter() const EXCLUSIVE_LOCK_FUNCTION() { 59 void CriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() {
60 #if defined(WEBRTC_WIN) 60 #if defined(WEBRTC_WIN)
61 EnterCriticalSection(&crit_); 61 EnterCriticalSection(&crit_);
62 #elif defined(WEBRTC_POSIX) 62 #elif defined(WEBRTC_POSIX)
63 # if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC 63 # if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
64 int spin = 3000; 64 int spin = 3000;
65 PlatformThreadRef self = CurrentThreadRef(); 65 PlatformThreadRef self = CurrentThreadRef();
66 bool have_lock = false; 66 bool have_lock = false;
67 do { 67 do {
68 // Instead of calling TryEnter() in this loop, we do two interlocked 68 // Instead of calling TryEnter() in this loop, we do two interlocked
69 // operations, first a read-only one in order to avoid affecting the lock 69 // operations, first a read-only one in order to avoid affecting the lock
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } else { 108 } else {
109 RTC_DCHECK(CurrentThreadIsOwner()); 109 RTC_DCHECK(CurrentThreadIsOwner());
110 } 110 }
111 ++recursion_count_; 111 ++recursion_count_;
112 # endif 112 # endif
113 #else 113 #else
114 # error Unsupported platform. 114 # error Unsupported platform.
115 #endif 115 #endif
116 } 116 }
117 117
118 bool CriticalSection::TryEnter() const EXCLUSIVE_TRYLOCK_FUNCTION(true) { 118 bool CriticalSection::TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
119 #if defined(WEBRTC_WIN) 119 #if defined(WEBRTC_WIN)
120 return TryEnterCriticalSection(&crit_) != FALSE; 120 return TryEnterCriticalSection(&crit_) != FALSE;
121 #elif defined(WEBRTC_POSIX) 121 #elif defined(WEBRTC_POSIX)
122 # if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC 122 # if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
123 if (!IsThreadRefEqual(owning_thread_, CurrentThreadRef())) { 123 if (!IsThreadRefEqual(owning_thread_, CurrentThreadRef())) {
124 if (AtomicOps::CompareAndSwap(&lock_queue_, 0, 1) != 0) 124 if (AtomicOps::CompareAndSwap(&lock_queue_, 0, 1) != 0)
125 return false; 125 return false;
126 owning_thread_ = CurrentThreadRef(); 126 owning_thread_ = CurrentThreadRef();
127 RTC_DCHECK(!recursion_); 127 RTC_DCHECK(!recursion_);
128 } else { 128 } else {
(...skipping 12 matching lines...) Expand all
141 RTC_DCHECK(CurrentThreadIsOwner()); 141 RTC_DCHECK(CurrentThreadIsOwner());
142 } 142 }
143 ++recursion_count_; 143 ++recursion_count_;
144 # endif 144 # endif
145 return true; 145 return true;
146 #else 146 #else
147 # error Unsupported platform. 147 # error Unsupported platform.
148 #endif 148 #endif
149 } 149 }
150 150
151 void CriticalSection::Leave() const UNLOCK_FUNCTION() { 151 void CriticalSection::Leave() const RTC_UNLOCK_FUNCTION() {
152 RTC_DCHECK(CurrentThreadIsOwner()); 152 RTC_DCHECK(CurrentThreadIsOwner());
153 #if defined(WEBRTC_WIN) 153 #if defined(WEBRTC_WIN)
154 LeaveCriticalSection(&crit_); 154 LeaveCriticalSection(&crit_);
155 #elif defined(WEBRTC_POSIX) 155 #elif defined(WEBRTC_POSIX)
156 # if CS_DEBUG_CHECKS 156 # if CS_DEBUG_CHECKS
157 --recursion_count_; 157 --recursion_count_;
158 RTC_DCHECK(recursion_count_ >= 0); 158 RTC_DCHECK(recursion_count_ >= 0);
159 if (!recursion_count_) 159 if (!recursion_count_)
160 thread_ = 0; 160 thread_ = 0;
161 # endif 161 # endif
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 GlobalLockScope::GlobalLockScope(GlobalLockPod* lock) 243 GlobalLockScope::GlobalLockScope(GlobalLockPod* lock)
244 : lock_(lock) { 244 : lock_(lock) {
245 lock_->Lock(); 245 lock_->Lock();
246 } 246 }
247 247
248 GlobalLockScope::~GlobalLockScope() { 248 GlobalLockScope::~GlobalLockScope() {
249 lock_->Unlock(); 249 lock_->Unlock();
250 } 250 }
251 251
252 } // namespace rtc 252 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/rtc_base/criticalsection.h ('k') | webrtc/rtc_base/criticalsection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698