diff options
author | hnOsmium0001 <[email protected]> | 2022-04-17 20:08:57 -0700 |
---|---|---|
committer | hnOsmium0001 <[email protected]> | 2022-04-17 20:08:57 -0700 |
commit | d43508ba4843801cbbf1f42a27af260d4eef5701 (patch) | |
tree | 39c51368cfe8ec097c08f198877cf07e9ff835ee /source/RcPtr.hpp | |
parent | 509201784d6525fc26345e55a56ab81e4a7616b3 (diff) |
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); } } |