diff options
author | rtk0c <[email protected]> | 2022-04-17 20:08:57 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-04-17 20:08:57 -0700 |
commit | 5424a1d5434e3ddd911a504719918c2df027e2fd (patch) | |
tree | 6275aab13140d81dcc46c8290e73ac9a8bbb5605 /source/RcPtr.hpp | |
parent | afcac59c7d04f4337d6b04ebed8cac7e871ccc50 (diff) |
Changeset: 8 Initial work on sprites and texture system
Diffstat (limited to 'source/RcPtr.hpp')
-rw-r--r-- | source/RcPtr.hpp | 16 |
1 files changed, 9 insertions, 7 deletions
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 <cstddef> +#include <cstdint> #include <optional> #include <type_traits> 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 <class T, class TDeleter = DefaultDeleter<T>> @@ -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); } } |