зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1062533 - part 5 - add {Mutex,Monitor}::TryLock methods; r=mccr8
This plumbs the code from PlatformMutex up to the xpcom level.
This commit is contained in:
Родитель
42bd2abf83
Коммит
84a074ecfc
|
@ -349,6 +349,16 @@ void OffTheBooksMutex::Lock() {
|
|||
Acquire();
|
||||
}
|
||||
|
||||
bool OffTheBooksMutex::TryLock() {
|
||||
CheckAcquire();
|
||||
bool locked = this->tryLock();
|
||||
if (locked) {
|
||||
mOwningThread = PR_GetCurrentThread();
|
||||
Acquire();
|
||||
}
|
||||
return locked;
|
||||
}
|
||||
|
||||
void OffTheBooksMutex::Unlock() {
|
||||
Release();
|
||||
mOwningThread = nullptr;
|
||||
|
|
|
@ -30,6 +30,7 @@ class Monitor {
|
|||
~Monitor() {}
|
||||
|
||||
void Lock() { mMutex.Lock(); }
|
||||
bool TryLock() { return mMutex.TryLock(); }
|
||||
void Unlock() { mMutex.Unlock(); }
|
||||
|
||||
void Wait() { mCondVar.Wait(); }
|
||||
|
|
|
@ -65,6 +65,11 @@ class OffTheBooksMutex : public detail::MutexImpl, BlockingResourceBase {
|
|||
**/
|
||||
void Lock() { this->lock(); }
|
||||
|
||||
/**
|
||||
* Try to lock this mutex, returning true if we were successful.
|
||||
**/
|
||||
bool TryLock() { return this->tryLock(); }
|
||||
|
||||
/**
|
||||
* Unlock this mutex.
|
||||
**/
|
||||
|
@ -89,6 +94,7 @@ class OffTheBooksMutex : public detail::MutexImpl, BlockingResourceBase {
|
|||
|
||||
#else
|
||||
void Lock();
|
||||
bool TryLock();
|
||||
void Unlock();
|
||||
|
||||
void AssertCurrentThreadOwns() const;
|
||||
|
|
Загрузка…
Ссылка в новой задаче