зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1318965 - Removes the custom AtomicRefCount r=cpearce
MozReview-Commit-ID: BAGocY4nGiM --HG-- extra : rebase_source : 18562465c37b686ca1653862e5c4e096d9efefe9 extra : amend_source : ecc2ab9b15950c6291ea386004d82a67d5dde368
This commit is contained in:
Родитель
06bce5da83
Коммит
36c1319590
|
@ -21,41 +21,7 @@
|
|||
#include <assert.h>
|
||||
#include "ClearKeyUtils.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <atomic>
|
||||
typedef std::atomic<uint32_t> AtomicRefCount;
|
||||
#else
|
||||
class AtomicRefCount {
|
||||
public:
|
||||
explicit AtomicRefCount(uint32_t aValue)
|
||||
: mCount(aValue)
|
||||
, mMutex(GMPCreateMutex())
|
||||
{
|
||||
assert(mMutex);
|
||||
}
|
||||
~AtomicRefCount()
|
||||
{
|
||||
if (mMutex) {
|
||||
mMutex->Destroy();
|
||||
}
|
||||
}
|
||||
uint32_t operator--() {
|
||||
AutoLock lock(mMutex);
|
||||
return --mCount;
|
||||
}
|
||||
uint32_t operator++() {
|
||||
AutoLock lock(mMutex);
|
||||
return ++mCount;
|
||||
}
|
||||
operator uint32_t() {
|
||||
AutoLock lock(mMutex);
|
||||
return mCount;
|
||||
}
|
||||
private:
|
||||
uint32_t mCount;
|
||||
GMPMutex* mMutex;
|
||||
};
|
||||
#endif
|
||||
|
||||
// Note: Thread safe.
|
||||
class RefCounted {
|
||||
|
@ -81,7 +47,7 @@ protected:
|
|||
{
|
||||
assert(!mRefCount);
|
||||
}
|
||||
AtomicRefCount mRefCount;
|
||||
std::atomic<uint32_t> mRefCount;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
|
Загрузка…
Ссылка в новой задаче