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
--- 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.
*/