Bug 1318965 - Removes the custom AtomicRefCount r?cpearce draft
authorJay Harris <jharris@mozilla.com>
Fri, 16 Dec 2016 11:57:58 +1300
changeset 459507 a2d545834d4d033073a58940416a8d26765af2af
parent 459506 b1e98ecd166954f0a9e7e9ad8544504210998f49
child 459508 366f8da20f5b511eafcdcd20113d04d268f6321b
push id41243
push userbmo:jharris@mozilla.com
push dateThu, 12 Jan 2017 02:54:07 +0000
reviewerscpearce
bugs1318965
milestone53.0a1
Bug 1318965 - Removes the custom AtomicRefCount r?cpearce MozReview-Commit-ID: BAGocY4nGiM
media/gmp-clearkey/0.1/RefCounted.h
--- 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);
   }