diff options
author | Colin Cross <ccross@android.com> | 2017-06-06 03:49:11 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-06-06 03:49:11 +0000 |
commit | 3bb233dbba325674fd1f44d462554b4c5c264463 (patch) | |
tree | 44865f842035b9548435aedbd895817eacd2b7c2 /cpp/src/sfntly/port/refcount.h | |
parent | 645381723cf0d1078bb40d62f799c981d6bf8412 (diff) | |
parent | 7b02e0897503472e86dcb1a3f4addb2484e33815 (diff) | |
download | sfntly-3bb233dbba325674fd1f44d462554b4c5c264463.tar.gz |
Merge remote-tracking branch 'aosp/upstream-master' into master am: d7c3ad1d95 am: fd76129cde am: 3d3aab44bf am: ad302cbfd8 am: 31db13c42a am: 47b38c7df8 am: 1f8dca48cb am: 959c8f3447 am: e070d6c91d am: a47999b814 am: 193346642e
am: 7b02e08975
Change-Id: I141c890cfecbd075f08e91b337829259a95d6a1a
Diffstat (limited to 'cpp/src/sfntly/port/refcount.h')
-rw-r--r-- | cpp/src/sfntly/port/refcount.h | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/cpp/src/sfntly/port/refcount.h b/cpp/src/sfntly/port/refcount.h index eed5162..6353b08 100644 --- a/cpp/src/sfntly/port/refcount.h +++ b/cpp/src/sfntly/port/refcount.h @@ -99,22 +99,18 @@ namespace sfntly { +template <typename T> +class Ptr; + class RefCount { public: // Make gcc -Wnon-virtual-dtor happy. virtual ~RefCount() {} - virtual size_t AddRef() const = 0; - virtual size_t Release() const = 0; -}; - -template <typename T> -class NoAddRefRelease : public T { - public: - NoAddRefRelease(); - ~NoAddRefRelease(); - private: + template <typename T> + friend class Ptr; + virtual size_t AddRef() const = 0; virtual size_t Release() const = 0; }; @@ -142,6 +138,7 @@ class RefCounted : virtual public RefCount { return *this; } + private: virtual size_t AddRef() const { size_t new_count = AtomicIncrement(&ref_count_); DEBUG_OUTPUT("A "); @@ -224,8 +221,8 @@ class Ptr { return *p_; // It can throw! } - NoAddRefRelease<T>* operator->() const { - return (NoAddRefRelease<T>*)p_; // It can throw! + T* operator->() const { + return p_; // It can throw! } bool operator!() const { |