Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: include/core/SkRefCnt.h

Issue 247813005: teach TSAN about SkSpinlock, SkRefCnt, and SkOnce (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: undo Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkOnce.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRefCnt.h
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index 2ac68ddbcdff6c33c4c131fc18a35202af31d2a5..41c78293fa7f2824d9ecc755c085d7242b845ab2 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -37,7 +37,7 @@ public:
*/
virtual ~SkRefCntBase() {
#ifdef SK_DEBUG
- SkASSERT(this->unique());
+ SkASSERT(fRefCnt == 1);
fRefCnt = 0; // illegal value, to catch us if we reuse after delete
#endif
}
@@ -53,7 +53,6 @@ public:
// an unproctected read. Generally, don't read fRefCnt, and don't stifle this warning.
bool const unique = (1 == SK_ANNOTATE_UNPROTECTED_READ(fRefCnt));
if (unique) {
- SK_ANNOTATE_HAPPENS_AFTER(this);
// Acquire barrier (L/SL), if not provided by load of fRefCnt.
// Prevents user's 'unique' code from happening before decrements.
//TODO: issue the barrier.
@@ -64,7 +63,7 @@ public:
/** Increment the reference count. Must be balanced by a call to unref().
*/
void ref() const {
- SkASSERT(this->unsafeGetRefCnt() > 0);
+ SkASSERT(fRefCnt > 0);
sk_atomic_inc(&fRefCnt); // No barrier required.
}
@@ -73,11 +72,9 @@ public:
the object needs to have been allocated via new, and not on the stack.
*/
void unref() const {
- SkASSERT(this->unsafeGetRefCnt() > 0);
- SK_ANNOTATE_HAPPENS_BEFORE(this);
+ SkASSERT(fRefCnt > 0);
// Release barrier (SL/S), if not provided below.
if (sk_atomic_dec(&fRefCnt) == 1) {
- SK_ANNOTATE_HAPPENS_AFTER(this);
// Acquire barrier (L/SL), if not provided above.
// Prevents code in dispose from happening before the decrement.
sk_membar_acquire__after_atomic_dec();
@@ -87,7 +84,7 @@ public:
#ifdef SK_DEBUG
void validate() const {
- SkASSERT(this->unsafeGetRefCnt() > 0);
+ SkASSERT(fRefCnt > 0);
}
#endif
@@ -106,9 +103,6 @@ protected:
}
private:
- // OK for use in asserts, but not much else.
- int32_t unsafeGetRefCnt() { return SK_ANNOTATE_UNPROTECTED_READ(fRefCnt); }
-
/**
* Called when the ref count goes to 0.
*/
« no previous file with comments | « include/core/SkOnce.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698