Bug 1318965 - Removes the custom AtomicRefCount r?cpearce
MozReview-Commit-ID: BAGocY4nGiM
--- a/media/gmp-clearkey/0.1/RefCounted.h
+++ b/media/gmp-clearkey/0.1/RefCounted.h
@@ -16,51 +16,17 @@
#ifndef __RefCount_h__
#define __RefCount_h__
#include <stdint.h>
#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 {
public:
void AddRef() {
++mRefCount;
}
@@ -76,17 +42,17 @@ protected:
RefCounted()
: mRefCount(0)
{
}
virtual ~RefCounted()
{
assert(!mRefCount);
}
- AtomicRefCount mRefCount;
+ std::atomic<uint32_t> mRefCount;
};
template<class T>
class RefPtr {
public:
RefPtr(const RefPtr& src) {
Set(src.mPtr);
}