8template <
typename T, u
int16 SlabSize = 4096>
17 FSlab* Slab =
nullptr;
30 CurrentSlab =
new FSlab();
35 check(CurrentSlab->Allocated == CurrentSlab->Freed);
53 uint16 ElementIndex = CurrentSlab->Allocated++;
55 FElement* Element = CurrentSlab->Elements + ElementIndex;
56 Element->Slab = CurrentSlab;
57 if (CurrentSlab->Allocated ==
SlabSize)
60 CurrentSlab =
new FSlab();
62 return Element->Data.GetTypedPtr();
67 FElement* Element =
reinterpret_cast<FElement*
>(Ptr);
68 FSlab* Slab = Element->Slab;
72 check(Slab->Freed == Slab->Allocated);
78 FSlab* CurrentSlab =
nullptr;
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition IoAllocators.h:10
T * Alloc()
Definition IoAllocators.h:51
void Destroy(T *Ptr)
Definition IoAllocators.h:45
void Free(T *Ptr)
Definition IoAllocators.h:65
~TSingleThreadedSlabAllocator()
Definition IoAllocators.h:33
TSingleThreadedSlabAllocator()
Definition IoAllocators.h:28
T * Construct(ArgsType &&... Args)
Definition IoAllocators.h:40
Definition TypeCompatibleBytes.h:24