31template<
typename TAnnotation,
bool bAutoRemove>
44#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
81 AutoRTFM::EContextStatus Status = AutoRTFM::Close([
this]
83 AutoRTFM::PopOnCommitHandler(
this);
85 checkSlow(Status == AutoRTFM::EContextStatus::OnTrack);
113#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
124 ProcessRegistration();
128 void ProcessRegistration()
171 AddAnnotationInternal(
Object, Annotation);
196#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
207 ProcessRegistration();
232#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
243 ProcessRegistration();
255 SetAnnotationCacheKeyAndValue(
nullptr,
TAnnotation());
263#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
274 ProcessRegistration();
290 if (AutoRTFM::IsTransactional())
346 if (AutoRTFM::IsTransactional())
348 MaybeRegisterAutoRTFMHandlers();
360 if (AutoRTFM::IsTransactional())
362 MaybeRegisterAutoRTFMHandlers();
372 void MaybeRegisterAutoRTFMHandlers()
379 AutoRTFM::EContextStatus Status = AutoRTFM::Close([
this]
386 AutoRTFM::PushOnCommitHandler(
this, [
this]
393 checkSlow(Status == AutoRTFM::EContextStatus::OnTrack);
445template<
typename TAnnotation,
bool bAutoRemove>
485 return (
UObject*)InverseAnnotationMap.FindRef(Annotation);
493 if (Annotation.IsDefault())
522 AddAnnotationInternal(
Object, Annotation);
539 if (Annotation.IsDefault())
542 checkSlow(!InverseAnnotationMap.Find(Annotation));
558 InverseAnnotationMap.Empty();
688template<
typename TAnnotation,
bool bAutoRemove,
int32 NumAnnotationsPerChunk = 64 * 1024>
691 struct TAnnotationChunk
706 int32 NumAnnotations;
708 int32 MaxAnnotations;
710 uint32 CurrentAllocatedMemory;
712 uint32 MaxAllocatedMemory;
724 if (ChunkIndex >= Chunks.
Num())
737 ExpandChunksToIndex(
Index);
742 TAnnotationChunk& Chunk = Chunks[ChunkIndex];
747 MaxAllocatedMemory = FMath::Max(CurrentAllocatedMemory, MaxAllocatedMemory);
767 if (ChunkIndex >= Chunks.
Num())
772 TAnnotationChunk& Chunk = Chunks[ChunkIndex];
785 check(Chunk.Num >= 0);
788 delete[] Chunk.Items;
789 Chunk.Items =
nullptr;
795 check(NumAnnotations >= 0);
803 for (TAnnotationChunk& Chunk : Chunks)
805 delete[] Chunk.Items;
810 CurrentAllocatedMemory = 0;
811 MaxAllocatedMemory = 0;
818 void AddAnnotationInternal(
int32 Index, T&& Annotation)
821 if (Annotation.IsDefault())
823 FreeAnnotation(
Index);
827 if (NumAnnotations == 0 && Chunks.
Num() == 0)
830#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
849 , CurrentAllocatedMemory(0)
850 , MaxAllocatedMemory(0)
888 AddAnnotationInternal(
Index, Annotation);
912 if (NumAnnotations == 0 && Chunks.
Num() == 0)
915#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
923 ExpandChunksToIndex(
Index);
928 TAnnotationChunk& Chunk = Chunks[ChunkIndex];
933 MaxAllocatedMemory = FMath::Max(CurrentAllocatedMemory, MaxAllocatedMemory);
964 FreeAnnotation(
Index);
994 if (ChunkIndex < Chunks.
Num())
998 TAnnotationChunk& Chunk = Chunks[ChunkIndex];
999 if (Chunk.Items !=
nullptr)
1016 return NumAnnotations;
1026 return MaxAnnotations;
1037 return MaxAnnotations;
1058 FreeAllAnnotations();
1062#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
1077 for (TAnnotationChunk& Chunk : Chunks)
1079 if (Chunk.Num == 0 && Chunk.Items)
1081 delete[] Chunk.Items;
1082 Chunk.Items =
nullptr;
1094 for (
const TAnnotationChunk& Chunk : Chunks)
1101 return AllocatedSize;
1118#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
1151template<
typename TAnnotation,
bool bAutoRemove>
1164#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
1225 ProcessRegistration();
1239 ProcessRegistration();
1245 void ProcessRegistration()
1257 if (AnnotationArray.
Num() == 0)
1262 bRegistered =
false;
1275 template<
typename T>
1281 if (Annotation.IsDefault())
1283 RemoveAnnotationInternal(
Index);
1287 if (AnnotationArray.
Num() == 0)
1290#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
1297 if (
Index >= AnnotationArray.
Num())
1331 RemoveAnnotationInternal(
Index);
1355 AnnotationArray.
Empty();
1359#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
1368 ProcessRegistration();
1399 return AnnotationArray[
Index];
1428 if (
Index >= AnnotationArray.
Num())
1436 ProcessRegistration();
1438 return AnnotationArray[
Index];
1458 bool bRegistered =
false;
1467 enum {BitsPerElement =
sizeof(TBitType) * 8};
1478 RemoveAnnotation(
Index);
1483 RemoveAllAnnotations();
1492 RemoveAllAnnotations();
1505 if (AnnotationArray.
Num() == 0)
1509 if (
Index >= AnnotationArray.
Num() * BitsPerElement)
1512 int32 AddElements = (
AddNum + BitsPerElement - 1) / BitsPerElement;
1517 AnnotationArray[
Index / BitsPerElement] |= TBitType(TBitType(1) << (
Index % BitsPerElement));
1528 RemoveAnnotation(
Index);
1537 RemoveAllAnnotations();
1550 if (
Index < AnnotationArray.
Num() * BitsPerElement)
1552 return !!(AnnotationArray[
Index / BitsPerElement] & TBitType(TBitType(1) << (
Index % BitsPerElement)));
1571 if (
Index < AnnotationArray.
Num() * BitsPerElement)
1573 AnnotationArray[
Index / BitsPerElement] &=
~TBitType(TBitType(1) << (
Index % BitsPerElement));
1580 void RemoveAllAnnotations()
1583 AnnotationArray.
Empty();
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define ensureAlwaysMsgf(InExpression, InFormat,...)
Definition AssertionMacros.h:467
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TSAN_SAFE
Definition CoreMiscDefines.h:144
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ON_SCOPE_EXIT
Definition ScopeExit.h:73
@ SLT_ReadOnly
Definition ScopeRWLock.h:138
@ SLT_Write
Definition ScopeRWLock.h:139
::FCriticalSection FTransactionallySafeCriticalSection
Definition TransactionallySafeCriticalSection.h:16
FUObjectArray GUObjectArray
Definition UObjectHash.cpp:55
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition UObjectAnnotation.h:690
void AddAnnotation(const UObjectBase *Object, const TAnnotation &Annotation)
Definition UObjectAnnotation.h:867
void RemoveAnnotation(int32 Index)
Definition UObjectAnnotation.h:961
void RemoveAllAnnotations()
Definition UObjectAnnotation.h:1054
UE_FORCEINLINE_HINT int32 GetAnnotationCount() const
Definition UObjectAnnotation.h:1014
virtual void OnUObjectArrayShutdown() override
Definition UObjectAnnotation.h:1131
virtual SIZE_T GetAllocatedSize() const override
Definition UObjectAnnotation.h:1091
TAnnotation & AddOrGetAnnotation(int32 Index, TFunctionRef< TAnnotation()> NewAnnotationFn)
Definition UObjectAnnotation.h:908
FUObjectAnnotationChunked() TSAN_SAFE
Definition UObjectAnnotation.h:846
virtual ~FUObjectAnnotationChunked()
Definition UObjectAnnotation.h:854
uint32 GetMaxAllocatedSize() const
Definition UObjectAnnotation.h:1105
void AddAnnotation(const UObjectBase *Object, TAnnotation &&Annotation)
Definition UObjectAnnotation.h:873
UE_FORCEINLINE_HINT int32 GetMaxAnnotations() const TSAN_SAFE
Definition UObjectAnnotation.h:1024
TAnnotation & AddOrGetAnnotation(const UObjectBase *Object, TFunctionRef< TAnnotation()> NewAnnotationFn)
Definition UObjectAnnotation.h:897
UE_FORCEINLINE_HINT int32 GetMaxAnnottations() const TSAN_SAFE
Definition UObjectAnnotation.h:1035
void AddAnnotation(int32 Index, TAnnotation &&Annotation)
Definition UObjectAnnotation.h:891
void RemoveAnnotation(const UObjectBase *Object)
Definition UObjectAnnotation.h:951
TAnnotation GetAnnotation(int32 Index)
Definition UObjectAnnotation.h:983
void AddAnnotation(int32 Index, const TAnnotation &Annotation)
Definition UObjectAnnotation.h:885
UE_FORCEINLINE_HINT bool IsValidIndex(int32 Index) const
Definition UObjectAnnotation.h:1046
TAnnotation GetAnnotation(const UObjectBase *Object)
Definition UObjectAnnotation.h:972
void TrimAnnotations()
Definition UObjectAnnotation.h:1074
virtual void NotifyUObjectDeleted(const UObjectBase *Object, int32 Index)
Definition UObjectAnnotation.h:1116
Definition UObjectAnnotation.h:1465
void Set(const UObjectBase *Object)
Definition UObjectAnnotation.h:1500
void Clear(const UObjectBase *Object)
Definition UObjectAnnotation.h:1524
virtual SIZE_T GetAllocatedSize() const override
Definition UObjectAnnotation.h:1557
virtual void NotifyUObjectDeleted(const UObjectBase *Object, int32 Index)
Definition UObjectAnnotation.h:1476
virtual ~FUObjectAnnotationDenseBool()
Definition UObjectAnnotation.h:1490
bool Get(const UObjectBase *Object)
Definition UObjectAnnotation.h:1545
UE_FORCEINLINE_HINT void ClearAll()
Definition UObjectAnnotation.h:1535
virtual void OnUObjectArrayShutdown() override
Definition UObjectAnnotation.h:1481
Definition UObjectAnnotation.h:1153
void AddAnnotation(const UObjectBase *Object, TAnnotation &&Annotation)
Definition UObjectAnnotation.h:1203
virtual void OnUObjectArrayShutdown() override
Definition UObjectAnnotation.h:1177
void AddAnnotation(int32 Index, const TAnnotation &Annotation)
Definition UObjectAnnotation.h:1215
virtual ~FUObjectAnnotationDense()
Definition UObjectAnnotation.h:1186
void RemoveAnnotation(int32 Index)
Definition UObjectAnnotation.h:1328
void RemoveAllAnnotations()
Definition UObjectAnnotation.h:1349
virtual void NotifyUObjectDeleted(const UObjectBase *Object, int32 Index)
Definition UObjectAnnotation.h:1162
TAnnotation GetAnnotation(const UObjectBase *Object)
Definition UObjectAnnotation.h:1376
void AddAnnotation(int32 Index, TAnnotation &&Annotation)
Definition UObjectAnnotation.h:1229
virtual SIZE_T GetAllocatedSize() const override
Definition UObjectAnnotation.h:1442
TAnnotation & GetAnnotationRef(int32 Index)
Definition UObjectAnnotation.h:1423
void RemoveAnnotation(const UObjectBase *Object)
Definition UObjectAnnotation.h:1318
TAnnotation GetAnnotation(int32 Index)
Definition UObjectAnnotation.h:1393
void AddAnnotation(const UObjectBase *Object, const TAnnotation &Annotation)
Definition UObjectAnnotation.h:1197
TAnnotation & GetAnnotationRef(const UObjectBase *Object)
Definition UObjectAnnotation.h:1410
Definition UObjectAnnotation.h:619
UE_FORCEINLINE_HINT int32 Num() const
Definition UObjectAnnotation.h:667
UE_FORCEINLINE_HINT void Reserve(int32 ExpectedNumElements)
Definition UObjectAnnotation.h:662
UE_FORCEINLINE_HINT void ClearAll()
Definition UObjectAnnotation.h:644
UE_FORCEINLINE_HINT void Set(const UObjectBase *Object)
Definition UObjectAnnotation.h:626
UE_FORCEINLINE_HINT bool Get(const UObjectBase *Object)
Definition UObjectAnnotation.h:654
UE_FORCEINLINE_HINT void Clear(const UObjectBase *Object)
Definition UObjectAnnotation.h:635
Definition UObjectAnnotation.h:447
virtual void OnUObjectArrayShutdown() override
Definition UObjectAnnotation.h:461
void RemoveAllAnnotations()
Definition UObjectAnnotation.h:554
void AddAnnotation(const UObjectBase *Object, TAnnotation &&Annotation)
Definition UObjectAnnotation.h:525
virtual void NotifyUObjectDeleted(const UObjectBase *Object, int32 Index) override
Definition UObjectAnnotation.h:456
UObject * Find(const TAnnotation &Annotation)
Definition UObjectAnnotation.h:481
virtual SIZE_T GetAllocatedSize() const override
Definition UObjectAnnotation.h:561
void RemoveAnnotation(const UObjectBase *Object)
Definition UObjectAnnotation.h:535
virtual ~FUObjectAnnotationSparseSearchable()
Definition UObjectAnnotation.h:470
void AddAnnotation(const UObjectBase *Object, const TAnnotation &Annotation)
Definition UObjectAnnotation.h:520
Definition UObjectAnnotation.h:33
virtual void NotifyUObjectDeleted(const UObjectBase *Object, int32 Index) override
Definition UObjectAnnotation.h:42
void AddAnnotation(const UObjectBase *Object, const TAnnotation &Annotation)
Definition UObjectAnnotation.h:169
TAnnotation GetAndRemoveAnnotation(const UObjectBase *Object)
Definition UObjectAnnotation.h:179
FTransactionallySafeRWLock AnnotationMapCritical
Definition UObjectAnnotation.h:402
virtual void OnUObjectArrayShutdown() override
Definition UObjectAnnotation.h:58
TAnnotation GetAnnotation(const UObjectBase *Object)
Definition UObjectAnnotation.h:283
FTransactionallySafeRWLock AnnotationCacheCritical
Definition UObjectAnnotation.h:403
const UObjectBase * AnnotationCacheKey
Definition UObjectAnnotation.h:414
void RemoveAllAnnotations()
Definition UObjectAnnotation.h:250
void Reserve(int32 ExpectedNumElements)
Definition UObjectAnnotation.h:326
TMap< const UObjectBase *, TAnnotation > AnnotationMap
Definition UObjectAnnotation.h:408
bool bRegistered
Definition UObjectAnnotation.h:424
const TMap< const UObjectBase *, TAnnotation > & GetAnnotationMap() const
Definition UObjectAnnotation.h:318
FUObjectAnnotationSparse()
Definition UObjectAnnotation.h:67
virtual ~FUObjectAnnotationSparse()
Definition UObjectAnnotation.h:76
void AddAnnotation(const UObjectBase *Object, TAnnotation &&Annotation)
Definition UObjectAnnotation.h:164
void RemoveAnnotation(const UObjectBase *Object)
Definition UObjectAnnotation.h:216
TAnnotation AnnotationCacheValue
Definition UObjectAnnotation.h:419
virtual SIZE_T GetAllocatedSize() const override
Definition UObjectAnnotation.h:332
Definition UObjectArray.h:984
UE_FORCEINLINE_HINT int32 ObjectToIndex(const class UObjectBase *Object) const
Definition UObjectArray.h:1078
COREUOBJECT_API void AddUObjectDeleteListener(FUObjectDeleteListener *Listener)
Definition UObjectArray.cpp:458
COREUOBJECT_API void RemoveUObjectDeleteListener(FUObjectDeleteListener *Listener)
Definition UObjectArray.cpp:472
void UnlockUObjectDeleteListeners()
Definition UObjectArray.h:1476
void LockUObjectDeleteListeners()
Definition UObjectArray.h:1468
UE_FORCEINLINE_HINT SizeType AddUninitialized()
Definition Array.h:1664
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT ElementType * GetData() UE_LIFETIMEBOUND
Definition Array.h:1027
SizeType AddZeroed()
Definition Array.h:2755
UE_NODEBUG UE_FORCEINLINE_HINT SIZE_T GetAllocatedSize(void) const
Definition Array.h:1059
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition AssetRegistryState.h:50
Definition UnrealString.h.inl:34
Definition ScopeRWLock.h:154
Definition ScopeRWLock.h:21
Definition ScopeLock.h:21
Definition ScopeRWLock.h:60
Definition UObjectBaseUtility.h:45
Definition UObjectBase.h:59
@ Start
Definition GeoEnum.h:100
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition UObjectAnnotation.h:576
UE_FORCEINLINE_HINT bool IsDefault()
Definition UObjectAnnotation.h:597
FBoolAnnotation()
Definition UObjectAnnotation.h:581
bool Mark
Definition UObjectAnnotation.h:605
FBoolAnnotation(bool InMark)
Definition UObjectAnnotation.h:589
Definition IsPODType.h:12
@ Value
Definition IsPODType.h:13