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

Unified Diff: include/core/SkRefCnt.h

Issue 18770007: Add a 'unique' method to SkRefCnt, document the usage, and add support. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Update comments. Created 7 years, 5 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 | « no previous file | src/core/SkPathRef.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRefCnt.h
===================================================================
--- include/core/SkRefCnt.h (revision 10200)
+++ include/core/SkRefCnt.h (working copy)
@@ -41,10 +41,22 @@
#endif
}
- /** Return the reference count.
- */
+ /** Return the reference count. Use only for debugging. */
int32_t getRefCnt() const { return fRefCnt; }
+ /** Returns true if the caller is the only owner.
+ * Ensures that all previous owner's actions are complete.
+ */
+ bool unique() const {
+ bool const unique = (1 == fRefCnt);
+ if (unique) {
+ // Aquire barrier (L/SL), if not provided by load of fRefCnt.
+ // Prevents user's 'unique' code from happening before decrements.
+ //TODO: issue the barrier.
+ }
+ return unique;
+ }
+
/** Increment the reference count. Must be balanced by a call to unref().
*/
void ref() const {
@@ -72,16 +84,6 @@
}
/**
- * Alias for ref(), for compatibility with scoped_refptr.
- */
- void AddRef() { this->ref(); }
-
- /**
- * Alias for unref(), for compatibility with scoped_refptr.
- */
- void Release() { this->unref(); }
-
- /**
* Alias for unref(), for compatibility with WTF::RefPtr.
*/
void deref() { this->unref(); }
@@ -109,9 +111,10 @@
SkDELETE(this);
}
+ // The following friends are those which override internal_dispose()
+ // and conditionally call SkRefCnt::internal_dispose().
+ friend class GrTexture;
friend class SkWeakRefCnt;
- friend class GrTexture; // to allow GrTexture's internal_dispose to
- // call SkRefCnt's & directly set fRefCnt (to 1)
mutable int32_t fRefCnt;
« no previous file with comments | « no previous file | src/core/SkPathRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698