Rename USE_NATIVE_MUTEX_ON_MAC to RTC_USE_NATIVE_MUTEX_ON_MAC.
WebRTC internal macros should be prefixed by RTC_. Bug: None Change-Id: I1a0be41ca1ea35173edf34bc190fc425c5f2c67b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144782 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28509}
This commit is contained in:

committed by
Commit Bot

parent
34462f5dc3
commit
a0eefc17f7
@ -31,7 +31,7 @@ CriticalSection::CriticalSection() {
|
|||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
InitializeCriticalSection(&crit_);
|
InitializeCriticalSection(&crit_);
|
||||||
#elif defined(WEBRTC_POSIX)
|
#elif defined(WEBRTC_POSIX)
|
||||||
#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
|
#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC
|
||||||
lock_queue_ = 0;
|
lock_queue_ = 0;
|
||||||
owning_thread_ = 0;
|
owning_thread_ = 0;
|
||||||
recursion_ = 0;
|
recursion_ = 0;
|
||||||
@ -60,7 +60,7 @@ CriticalSection::~CriticalSection() {
|
|||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
DeleteCriticalSection(&crit_);
|
DeleteCriticalSection(&crit_);
|
||||||
#elif defined(WEBRTC_POSIX)
|
#elif defined(WEBRTC_POSIX)
|
||||||
#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
|
#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC
|
||||||
dispatch_release(semaphore_);
|
dispatch_release(semaphore_);
|
||||||
#else
|
#else
|
||||||
pthread_mutex_destroy(&mutex_);
|
pthread_mutex_destroy(&mutex_);
|
||||||
@ -74,7 +74,7 @@ void CriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() {
|
|||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
EnterCriticalSection(&crit_);
|
EnterCriticalSection(&crit_);
|
||||||
#elif defined(WEBRTC_POSIX)
|
#elif defined(WEBRTC_POSIX)
|
||||||
#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
|
#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC
|
||||||
int spin = 3000;
|
int spin = 3000;
|
||||||
PlatformThreadRef self = CurrentThreadRef();
|
PlatformThreadRef self = CurrentThreadRef();
|
||||||
bool have_lock = false;
|
bool have_lock = false;
|
||||||
@ -133,7 +133,7 @@ bool CriticalSection::TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
|
|||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
return TryEnterCriticalSection(&crit_) != FALSE;
|
return TryEnterCriticalSection(&crit_) != FALSE;
|
||||||
#elif defined(WEBRTC_POSIX)
|
#elif defined(WEBRTC_POSIX)
|
||||||
#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
|
#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC
|
||||||
if (!IsThreadRefEqual(owning_thread_, CurrentThreadRef())) {
|
if (!IsThreadRefEqual(owning_thread_, CurrentThreadRef())) {
|
||||||
if (AtomicOps::CompareAndSwap(&lock_queue_, 0, 1) != 0)
|
if (AtomicOps::CompareAndSwap(&lock_queue_, 0, 1) != 0)
|
||||||
return false;
|
return false;
|
||||||
@ -173,7 +173,7 @@ void CriticalSection::Leave() const RTC_UNLOCK_FUNCTION() {
|
|||||||
if (!recursion_count_)
|
if (!recursion_count_)
|
||||||
thread_ = 0;
|
thread_ = 0;
|
||||||
#endif
|
#endif
|
||||||
#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
|
#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC
|
||||||
RTC_DCHECK(IsThreadRefEqual(owning_thread_, CurrentThreadRef()));
|
RTC_DCHECK(IsThreadRefEqual(owning_thread_, CurrentThreadRef()));
|
||||||
RTC_DCHECK_GE(recursion_, 0);
|
RTC_DCHECK_GE(recursion_, 0);
|
||||||
--recursion_;
|
--recursion_;
|
||||||
@ -217,14 +217,15 @@ CritScope::~CritScope() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GlobalLockPod::Lock() {
|
void GlobalLockPod::Lock() {
|
||||||
#if !defined(WEBRTC_WIN) && (!defined(WEBRTC_MAC) || USE_NATIVE_MUTEX_ON_MAC)
|
#if !defined(WEBRTC_WIN) && \
|
||||||
|
(!defined(WEBRTC_MAC) || RTC_USE_NATIVE_MUTEX_ON_MAC)
|
||||||
const struct timespec ts_null = {0};
|
const struct timespec ts_null = {0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (AtomicOps::CompareAndSwap(&lock_acquired, 0, 1)) {
|
while (AtomicOps::CompareAndSwap(&lock_acquired, 0, 1)) {
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
::Sleep(0);
|
::Sleep(0);
|
||||||
#elif defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
|
#elif defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC
|
||||||
sched_yield();
|
sched_yield();
|
||||||
#else
|
#else
|
||||||
nanosleep(&ts_null, nullptr);
|
nanosleep(&ts_null, nullptr);
|
||||||
|
@ -34,9 +34,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// See notes in the 'Performance' unit test for the effects of this flag.
|
// See notes in the 'Performance' unit test for the effects of this flag.
|
||||||
#define USE_NATIVE_MUTEX_ON_MAC 1
|
#define RTC_USE_NATIVE_MUTEX_ON_MAC 1
|
||||||
|
|
||||||
#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
|
#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC
|
||||||
#include <dispatch/dispatch.h>
|
#include <dispatch/dispatch.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class RTC_LOCKABLE CriticalSection {
|
|||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
mutable CRITICAL_SECTION crit_;
|
mutable CRITICAL_SECTION crit_;
|
||||||
#elif defined(WEBRTC_POSIX)
|
#elif defined(WEBRTC_POSIX)
|
||||||
#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC
|
#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC
|
||||||
// Number of times the lock has been locked + number of threads waiting.
|
// Number of times the lock has been locked + number of threads waiting.
|
||||||
// TODO(tommi): We could use this number and subtract the recursion count
|
// TODO(tommi): We could use this number and subtract the recursion count
|
||||||
// to find places where we have multiple threads contending on the same lock.
|
// to find places where we have multiple threads contending on the same lock.
|
||||||
|
Reference in New Issue
Block a user