Bug 1295763 - Allow ThreadSafeAutoRefCnt with XPCOM_GLUE - r?jcranmer draft
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 16 Aug 2016 14:07:16 +1000
changeset 401341 a46f2a9446bd9c2363efed61bd0417c93c640edb
parent 400825 054d4856cea6150a6638e5daf7913713281af97d
child 528469 d4dbf0250e7ad5961db67263b1afa8f6bfb00ace
push id26438
push usergsquelart@mozilla.com
push dateTue, 16 Aug 2016 22:13:03 +0000
reviewersjcranmer
bugs1295763
milestone51.0a1
Bug 1295763 - Allow ThreadSafeAutoRefCnt with XPCOM_GLUE - r?jcranmer Removed '#ifndef XPCOM_GLUE' that blocked usage of thread-safe ref-counting from XPCOM_GLUE code. MozReview-Commit-ID: Hm0rdTKK46l
xpcom/glue/nsISupportsImpl.h
--- a/xpcom/glue/nsISupportsImpl.h
+++ b/xpcom/glue/nsISupportsImpl.h
@@ -15,19 +15,17 @@
 
 
 #if !defined(XPCOM_GLUE_AVOID_NSPR)
 #include "prthread.h" /* needed for thread-safety checks */
 #endif // !XPCOM_GLUE_AVOID_NSPR
 
 #include "nsDebug.h"
 #include "nsXPCOM.h"
-#ifndef XPCOM_GLUE
 #include "mozilla/Atomics.h"
-#endif
 #include "mozilla/Attributes.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Compiler.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MacroArgs.h"
 #include "mozilla/MacroForEach.h"
 #include "mozilla/TypeTraits.h"
 
@@ -326,17 +324,16 @@ public:
 
   static const bool isThreadSafe = false;
 private:
   nsrefcnt operator++(int) = delete;
   nsrefcnt operator--(int) = delete;
   nsrefcnt mValue;
 };
 
-#ifndef XPCOM_GLUE
 namespace mozilla {
 class ThreadSafeAutoRefCnt
 {
 public:
   ThreadSafeAutoRefCnt() : mValue(0) {}
   explicit ThreadSafeAutoRefCnt(nsrefcnt aValue) : mValue(aValue) {}
 
   // only support prefix increment/decrement
@@ -355,17 +352,16 @@ private:
   nsrefcnt operator++(int) = delete;
   nsrefcnt operator--(int) = delete;
   // In theory, RelaseAcquire consistency (but no weaker) is sufficient for
   // the counter. Making it weaker could speed up builds on ARM (but not x86),
   // but could break pre-existing code that assumes sequential consistency.
   Atomic<nsrefcnt> mValue;
 };
 } // namespace mozilla
-#endif
 
 ///////////////////////////////////////////////////////////////////////////////
 
 /**
  * Declare the reference count variable and the implementations of the
  * AddRef and QueryInterface methods.
  */