зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1062533 - part 4 - expose a tryLock method for PlatformMutex; r=mccr8
Chromium IPC locks have this and the API gets used, so we need to expose it ourselves if we're going to use our locks in place of the Chromium IPC locks. This patch changes the mozglue parts; tweaking the xpcom parts is the next patch.
This commit is contained in:
Родитель
99da46a21c
Коммит
42bd2abf83
|
@ -127,8 +127,9 @@ inline void mozilla::detail::MutexImpl::mutexLock() {
|
|||
"mozilla::detail::MutexImpl::mutexLock: pthread_mutex_lock failed");
|
||||
}
|
||||
|
||||
#ifdef XP_DARWIN
|
||||
inline bool mozilla::detail::MutexImpl::mutexTryLock() {
|
||||
bool mozilla::detail::MutexImpl::tryLock() { return mutexTryLock(); }
|
||||
|
||||
bool mozilla::detail::MutexImpl::mutexTryLock() {
|
||||
int result = pthread_mutex_trylock(&platformData()->ptMutex);
|
||||
if (result == 0) {
|
||||
return true;
|
||||
|
@ -142,7 +143,6 @@ inline bool mozilla::detail::MutexImpl::mutexTryLock() {
|
|||
result,
|
||||
"mozilla::detail::MutexImpl::mutexTryLock: pthread_mutex_trylock failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
void mozilla::detail::MutexImpl::lock() {
|
||||
#ifndef XP_DARWIN
|
||||
|
|
|
@ -22,6 +22,12 @@ void mozilla::detail::MutexImpl::lock() {
|
|||
AcquireSRWLockExclusive(&platformData()->lock);
|
||||
}
|
||||
|
||||
bool mozilla::detail::MutexImpl::tryLock() { return mutexTryLock(); }
|
||||
|
||||
bool mozilla::detail::MutexImpl::mutexTryLock() {
|
||||
return !!TryAcquireSRWLockExclusive(&platformData()->lock);
|
||||
}
|
||||
|
||||
void mozilla::detail::MutexImpl::unlock() {
|
||||
ReleaseSRWLockExclusive(&platformData()->lock);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,9 @@ class MutexImpl {
|
|||
protected:
|
||||
MFBT_API void lock();
|
||||
MFBT_API void unlock();
|
||||
// We have a separate, forwarding API so internal uses don't have to go
|
||||
// through the PLT.
|
||||
MFBT_API bool tryLock();
|
||||
|
||||
private:
|
||||
MutexImpl(const MutexImpl&) = delete;
|
||||
|
@ -42,9 +45,7 @@ class MutexImpl {
|
|||
bool operator==(const MutexImpl& rhs) = delete;
|
||||
|
||||
void mutexLock();
|
||||
#ifdef XP_DARWIN
|
||||
bool mutexTryLock();
|
||||
#endif
|
||||
|
||||
PlatformData* platformData();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче