From 5424a1d5434e3ddd911a504719918c2df027e2fd Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 17 Apr 2022 20:08:57 -0700 Subject: Changeset: 8 Initial work on sprites and texture system --- source/RcPtr.hpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source/RcPtr.hpp') diff --git a/source/RcPtr.hpp b/source/RcPtr.hpp index 5958db4..130b2b2 100644 --- a/source/RcPtr.hpp +++ b/source/RcPtr.hpp @@ -4,13 +4,15 @@ #include "TypeTraits.hpp" #include +#include #include #include class RefCounted { public: // DO NOT MODIFY this field, unless explicitly documented the use - size_t refCount = 0; + uint32_t refCount = 0; + uint32_t weakCount = 0; // TODO implement }; template > @@ -27,7 +29,7 @@ public: explicit RcPtr(T* ptr) : mPtr{ ptr } { if (ptr) { - ++ptr->refCount; + ++ptr->RefCounted::refCount; } } @@ -39,7 +41,7 @@ public: CleanUp(); mPtr = ptr; if (ptr) { - ++ptr->refCount; + ++ptr->RefCounted::refCount; } } @@ -51,7 +53,7 @@ public: RcPtr(const RcPtr& that) : mPtr{ that.mPtr } { if (mPtr) { - ++mPtr->refCount; + ++mPtr->RefCounted::refCount; } } @@ -59,7 +61,7 @@ public: CleanUp(); mPtr = that.mPtr; if (mPtr) { - ++mPtr->refCount; + ++mPtr->RefCounted::refCount; } return *this; } @@ -109,8 +111,8 @@ public: private: void CleanUp() { if (mPtr) { - --mPtr->refCount; - if (mPtr->refCount == 0) { + --mPtr->RefCounted::refCount; + if (mPtr->RefCounted::refCount == 0) { TDeleter::operator()(mPtr); } } -- cgit v1.2.3-70-g09d2