39 UE_DEPRECATED(5.6,
"Inspecting an object's refcount is deprecated.")
66CORE_API void CheckRefCountIsNonZero();
68template <
typename AtomicType>
69class TTransactionalAtomicRefCount
72 template <auto DeleteFn>
110 template <auto DeleteFn>
116 CheckRefCountIsNonZero();
122 if (AutoRTFM::IsClosed())
159 Refs = RefCount.load(std::memory_order_relaxed);
165 template <auto DeleteFn>
178 CheckRefCountIsNonZero();
189 mutable std::atomic<AtomicType> RefCount = 0;
228 return Super::Release<DeleteThis>();
233 return Super::GetRefCount();
237 using Super = UE::Private::TTransactionalAtomicRefCount<uint32>;
239 static void DeleteThis(
const Super* This)
276 mutable int32 NumRefs;
292 check(Super::GetRefCount() == 0);
302 return Super::Release<DeleteThis>();
307 return Super::GetRefCount();
311 using Super = UE::Private::TTransactionalAtomicRefCount<uint32>;
313 static void DeleteThis(
const Super* This)
354template <
typename T, ERefCountingMode Mode = ERefCountingMode::ThreadSafe>
381 return Super::GetRefCount();
390 using Super = UE::Private::TTransactionalAtomicRefCount<uint32>;
392 static void StaticDestroyMixin(
const Super* This)
396 T::StaticDestroyObject(
static_cast<const T*
>(This));
423 StaticDestroyMixin(
this);
443 T::StaticDestroyObject(
static_cast<const T*
>(This));
452template<
typename ReferencedType>
471 Reference =
Copy.Reference;
478 template<
typename CopyReferencedType>
490 Reference =
Move.Reference;
491 Move.Reference =
nullptr;
494 template<
typename MoveReferencedType>
498 Move.Reference =
nullptr;
505 Reference->Release();
530 return *
this =
InPtr.Reference;
533 template<
typename CopyReferencedType>
544 Reference =
InPtr.Reference;
545 InPtr.Reference =
nullptr;
554 template<
typename MoveReferencedType>
559 Reference =
InPtr.Reference;
560 InPtr.Reference =
nullptr;
596 return Reference !=
nullptr;
609 Result = Reference->GetRefCount();
618 Reference =
InPtr.Reference;
635 template <
typename OtherType>
652#if !PLATFORM_COMPILER_HAS_GENERATED_COMPARISON_OPERATORS
653template<
typename ReferencedType>
656 return A ==
B.GetReference();
660template<
typename ReferencedType>
667template<
typename ReferencedType>
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ALIAS_TEMPLATE_TYPE_LAYOUT(TemplatePrefix, T, Alias)
Definition MemoryLayout.h:762
UE_FORCEINLINE_HINT uint32 GetTypeHash(const TRefCountPtr< ReferencedType > &InPtr)
Definition RefCounting.h:661
UE_FORCEINLINE_HINT bool operator==(ReferencedType *A, const TRefCountPtr< ReferencedType > &B)
Definition RefCounting.h:654
FArchive & operator<<(FArchive &Ar, TRefCountPtr< ReferencedType > &Ptr)
Definition RefCounting.h:668
TRefCountPtr< T > MakeRefCount(TArgs &&... Args)
Definition RefCounting.h:679
ERefCountingMode
Definition RefCounting.h:324
#define UE_REQUIRES(...)
Definition Requires.h:86
void Move(T &A, typename TMoveSupportTraits< T >::Copy B)
Definition UnrealTemplate.h:24
Definition Archive.h:1208
UE_FORCEINLINE_HINT bool IsLoading() const
Definition Archive.h:236
Definition RefCounting.h:213
uint32 GetRefCount() const
Definition RefCounting.h:231
FReturnedRefCountValue AddRef() const
Definition RefCounting.h:221
FRefCountBase(const FRefCountBase &Rhs)=delete
virtual ~FRefCountBase()=default
uint32 Release() const
Definition RefCounting.h:226
FRefCountBase & operator=(const FRefCountBase &Rhs)=delete
Definition RefCounting.h:252
virtual ~FRefCountedObject()
Definition RefCounting.h:255
FRefCountedObject()
Definition RefCounting.h:254
FReturnedRefCountValue AddRef() const
Definition RefCounting.h:258
FRefCountedObject & operator=(const FRefCountedObject &Rhs)=delete
uint32 Release() const
Definition RefCounting.h:262
FRefCountedObject(const FRefCountedObject &Rhs)=delete
uint32 GetRefCount() const
Definition RefCounting.h:271
Definition RefCounting.h:283
FThreadSafeRefCountedObject()=default
virtual ~FThreadSafeRefCountedObject()
Definition RefCounting.h:290
FReturnedRefCountValue AddRef() const
Definition RefCounting.h:295
uint32 GetRefCount() const
Definition RefCounting.h:305
FThreadSafeRefCountedObject(const FThreadSafeRefCountedObject &Rhs)=delete
FThreadSafeRefCountedObject & operator=(const FThreadSafeRefCountedObject &Rhs)=delete
uint32 Release() const
Definition RefCounting.h:300
Definition RefCounting.h:196
virtual uint32 GetRefCount() const =0
virtual ~IRefCountedObject()
Definition RefCounting.h:198
virtual uint32 Release() const =0
virtual FReturnedRefCountValue AddRef() const =0
Definition RefCounting.h:454
TRefCountPtr(TRefCountPtr< MoveReferencedType > &&Move)
Definition RefCounting.h:495
void Swap(TRefCountPtr &InPtr)
Definition RefCounting.h:615
UE_FORCEINLINE_HINT bool operator==(const TRefCountPtr &B) const
Definition RefCounting.h:639
UE_FORCEINLINE_HINT TRefCountPtr & operator=(const TRefCountPtr< CopyReferencedType > &InPtr)
Definition RefCounting.h:534
uint32 GetRefCount()
Definition RefCounting.h:604
TRefCountPtr(TRefCountPtr &&Move)
Definition RefCounting.h:488
void Serialize(FArchive &Ar)
Definition RefCounting.h:622
TRefCountPtr(const TRefCountPtr &Copy)
Definition RefCounting.h:469
ReferencedType ** GetInitReference()
Definition RefCounting.h:578
TRefCountPtr & operator=(ReferencedType *InReference)
Definition RefCounting.h:509
UE_FORCEINLINE_HINT TRefCountPtr & operator=(const TRefCountPtr &InPtr)
Definition RefCounting.h:528
TRefCountPtr(const TRefCountPtr< CopyReferencedType > &Copy)
Definition RefCounting.h:479
TRefCountPtr & operator=(TRefCountPtr< MoveReferencedType > &&InPtr)
Definition RefCounting.h:555
TRefCountPtr & operator=(TRefCountPtr &&InPtr)
Definition RefCounting.h:539
UE_FORCEINLINE_HINT ReferencedType * GetReference() const
Definition RefCounting.h:584
UE_FORCEINLINE_HINT ReferencedType * operator->() const
Definition RefCounting.h:568
UE_FORCEINLINE_HINT bool operator==(ReferencedType *B) const
Definition RefCounting.h:644
UE_FORCEINLINE_HINT friend bool IsValidRef(const TRefCountPtr &InReference)
Definition RefCounting.h:589
UE_FORCEINLINE_HINT bool IsValid() const
Definition RefCounting.h:594
TRefCountPtr(ReferencedType *InReference, bool bAddRef=true)
Definition RefCounting.h:460
UE_FORCEINLINE_HINT void SafeRelease()
Definition RefCounting.h:599
~TRefCountPtr()
Definition RefCounting.h:501
UE_FORCEINLINE_HINT TRefCountPtr()=default
TRefCountingMixin()=default
TRefCountingMixin & operator=(const TRefCountingMixin &)=delete
TRefCountingMixin(const TRefCountingMixin &)=delete
FReturnedRefCountValue AddRef() const
Definition RefCounting.h:412
static void StaticDestroyObject(const T *Obj)
Definition RefCounting.h:435
uint32 Release() const
Definition RefCounting.h:417
uint32 GetRefCount() const
Definition RefCounting.h:430
uint32 GetRefCount() const
Definition RefCounting.h:379
FReturnedRefCountValue AddRef() const
Definition RefCounting.h:369
TRefCountingMixin()=default
uint32 Release() const
Definition RefCounting.h:374
TRefCountingMixin(const TRefCountingMixin &)=delete
static void StaticDestroyObject(const T *Obj)
Definition RefCounting.h:384
TRefCountingMixin & operator=(const TRefCountingMixin &)=delete
Definition RefCounting.h:355
@ Release
Definition PhysicsPublic.h:123
Definition PackageReader.cpp:44
Definition RefCounting.h:29
FReturnedRefCountValue & operator=(FReturnedRefCountValue &&Other)=default
FReturnedRefCountValue(FReturnedRefCountValue &&Other)=default
FReturnedRefCountValue(const FReturnedRefCountValue &Other)=default
FReturnedRefCountValue & operator=(const FReturnedRefCountValue &Other)=default
void CheckAtLeast(uint32 N) const
Definition RefCounting.h:45
FReturnedRefCountValue(uint32 InRefCount)
Definition RefCounting.h:30