Bug 1318965 - Removes the custom AtomicRefCount r=cpearce
authorJay Harris <jharris@mozilla.com>
Fri, 16 Dec 2016 11:57:58 +1300
changeset 374927 268335551186dd3c9bc9d3bdd50e133b9d7bea7b
parent 374926 fe0662dd0b839b00710eae1a7a4452625027a03a
child 374928 6f863c0059eb81d790f8c12e3ddc0a51f49dcc5e
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1318965
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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);
   }