12template <
class T>
class Ref;
57 mRefCount.fetch_add(1, memory_order_relaxed);
63 if (
mRefCount.fetch_sub(1, memory_order_release) == 1)
67 delete static_cast<const T *
>(
this);
116 inline operator T *()
const {
return mPtr; }
138 inline void AddRef() {
if (mPtr !=
nullptr) mPtr->AddRef(); }
139 inline void Release() {
if (mPtr !=
nullptr) mPtr->Release(); }
170 inline operator const T * ()
const {
return mPtr; }
185 inline const T *
GetPtr()
const {
return mPtr; }
192 inline void AddRef() {
if (mPtr !=
nullptr) mPtr->AddRef(); }
193 inline void Release() {
if (mPtr !=
nullptr) mPtr->Release(); }
209 size_t operator () (
const JPH::Ref<T> &
inRHS)
const
219 size_t operator () (
const JPH::RefConst<T> &
inRHS)
const
#define JPH_EXPORT
Definition Core.h:227
#define JPH_NAMESPACE_END
Definition Core.h:367
#define JPH_CLANG_SUPPRESS_WARNING(w)
Definition Core.h:254
std::uint32_t uint32
Definition Core.h:442
#define JPH_NAMESPACE_BEGIN
Definition Core.h:361
#define JPH_IF_ENABLE_ASSERTS(...)
Definition IssueReporting.h:35
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
AllocateFunction Allocate
Definition Memory.cpp:59
Definition Reference.h:151
const T * GetPtr() const
Get pointer.
Definition Reference.h:185
bool operator!=(const T *inRHS) const
Definition Reference.h:180
RefConst()
Constructor.
Definition Reference.h:154
~RefConst()
Definition Reference.h:160
RefConst(const T *inRHS)
Definition Reference.h:155
const T & operator*() const
Definition Reference.h:174
RefConst< T > & operator=(const T *inRHS)
Assignment operators.
Definition Reference.h:163
RefConst(const Ref< T > &inRHS)
Definition Reference.h:158
void ** InternalGetPointer()
INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
Definition Reference.h:188
const T * operator->() const
Access like a normal pointer.
Definition Reference.h:173
RefConst(RefConst< T > &&inRHS) noexcept
Definition Reference.h:157
RefConst(const RefConst< T > &inRHS)
Definition Reference.h:156
bool operator==(const T *inRHS) const
Comparison.
Definition Reference.h:177
RefConst(Ref< T > &&inRHS) noexcept
Definition Reference.h:159
Definition Reference.h:101
Ref(const Ref< T > &inRHS)
Definition Reference.h:106
T * GetPtr() const
Get pointer.
Definition Reference.h:129
bool operator!=(const T *inRHS) const
Definition Reference.h:125
Ref()
Constructor.
Definition Reference.h:104
~Ref()
Definition Reference.h:108
T * operator->() const
Access like a normal pointer.
Definition Reference.h:119
void ** InternalGetPointer()
INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
Definition Reference.h:132
Ref< T > & operator=(T *inRHS)
Assignment operators.
Definition Reference.h:111
Ref(Ref< T > &&inRHS) noexcept
Definition Reference.h:107
Ref(T *inRHS)
Definition Reference.h:105
bool operator==(const T *inRHS) const
Comparison.
Definition Reference.h:123
T & operator*() const
Definition Reference.h:120
Definition Reference.h:35
void Release() const
Definition Reference.h:60
atomic< uint32 > mRefCount
Current reference count.
Definition Reference.h:77
RefTarget & operator=(const RefTarget &)
Assignment operator.
Definition Reference.h:48
void SetEmbedded() const
Definition Reference.h:45
RefTarget()=default
Constructor.
RefTarget(const RefTarget &)
Definition Reference.h:39
static int sInternalGetRefCountOffset()
INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
Definition Reference.h:72
~RefTarget()
assert no one is referencing us
Definition Reference.h:40
uint32 GetRefCount() const
Get current refcount of this object.
Definition Reference.h:51
void AddRef() const
Add or release a reference to this object.
Definition Reference.h:54
static constexpr uint32 cEmbedded
A large value that gets added to the refcount to mark the object as embedded.
Definition Reference.h:75
Pure virtual version of RefTarget.
Definition Reference.h:82
virtual ~RefTargetVirtual()=default
Virtual destructor.
virtual void Release()=0
Virtual release reference.
virtual void AddRef()=0
Virtual add reference.
Definition Reference.h:204