Remove SkRefCnt_SafeAssign.

Change-Id: I590e74c2de8e0c2b8d407bd869c97a4d3bd98fed
Reviewed-on: https://skia-review.googlesource.com/141041
Commit-Queue: Herb Derby <herb@google.com>
Auto-Submit: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
Ben Wagner 2018-07-12 11:13:52 -04:00 committed by Skia Commit-Bot
parent 9ec70c6bd3
commit 0277440d22

View File

@ -138,42 +138,6 @@ class SK_API SkRefCnt : public SkRefCntBase {
///////////////////////////////////////////////////////////////////////////////
/** Helper macro to safely assign one SkRefCnt[TS]* to another, checking for
null in on each side of the assignment, and ensuring that ref() is called
before unref(), in case the two pointers point to the same object.
*/
#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
// This version heuristically detects data races, since those otherwise result
// in redundant reference count decrements, which are exceedingly
// difficult to debug.
#define SkRefCnt_SafeAssign(dst, src) \
do { \
typedef typename std::remove_reference<decltype(dst)>::type \
SkRefCntPtrT; \
SkRefCntPtrT old_dst = *const_cast<SkRefCntPtrT volatile *>(&dst); \
if (src) src->ref(); \
if (old_dst) old_dst->unref(); \
if (old_dst != *const_cast<SkRefCntPtrT volatile *>(&dst)) { \
SkDebugf("Detected racing Skia calls at %s:%d\n", \
__FILE__, __LINE__); \
} \
dst = src; \
} while (0)
#else /* !SK_BUILD_FOR_ANDROID_FRAMEWORK */
#define SkRefCnt_SafeAssign(dst, src) \
do { \
if (src) src->ref(); \
if (dst) dst->unref(); \
dst = src; \
} while (0)
#endif
/** Call obj->ref() and return obj. The obj must not be nullptr.
*/
template <typename T> static inline T* SkRef(T* obj) {