aboutsummaryrefslogtreecommitdiff
path: root/source/RcPtr.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/RcPtr.hpp')
-rw-r--r--source/RcPtr.hpp16
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);
}
}