16template <
typename Object>
28 atomic<uint32> mNextFreeObject;
31 static_assert(
alignof(ObjectStorage) ==
alignof(
Object),
"Object not properly aligned");
34 const ObjectStorage & GetStorage(
uint32 inObjectIndex)
const {
return mPages[inObjectIndex >> mPageShift][inObjectIndex & mObjectMask]; }
35 ObjectStorage & GetStorage(
uint32 inObjectIndex) {
return mPages[inObjectIndex >> mPageShift][inObjectIndex & mObjectMask]; }
51 atomic<uint32> mNumObjectsAllocated;
54 ObjectStorage ** mPages =
nullptr;
62#ifdef JPH_ENABLE_ASSERTS
63 atomic<uint32> mNumFreeObjects;
67 atomic<uint32> mAllocationTag;
70 atomic<uint64> mFirstFreeObjectAndTag;
73 atomic<uint32> mFirstFreeObjectInNewPage;
89 template <
typename... Parameters>
115 inline Object &
Get(
uint32 inObjectIndex) {
return GetStorage(inObjectIndex).mObject; }
118 inline const Object &
Get(
uint32 inObjectIndex)
const {
return GetStorage(inObjectIndex).mObject; }
#define JPH_CACHE_LINE_SIZE
Definition Core.h:613
unsigned int uint
Definition Core.h:564
#define JPH_NAMESPACE_END
Definition Core.h:487
std::uint32_t uint32
Definition Core.h:567
#define JPH_NAMESPACE_BEGIN
Definition Core.h:481
@ Object
Start of a new object.
Definition SerializableAttribute.h:20
Definition FixedSizeFreeList.h:18
void Init(uint inMaxObjects, uint inPageSize)
Initialize the free list, up to inMaxObjects can be allocated.
Definition FixedSizeFreeList.inl:25
void DestructObjectBatch(Batch &ioBatch)
Lockless destruct batch of objects.
Definition FixedSizeFreeList.inl:130
uint32 GetObjectIndex(const Object *inObject) const
Get the index of an object that was created by this free list.
Definition FixedSizeFreeList.inl:210
uint32 ConstructObject(Parameters &&... inParameters)
Lockless construct a new object, inParameters are passed on to the constructor.
Definition FixedSizeFreeList.inl:54
static const int ObjectStorageSize
Definition FixedSizeFreeList.h:80
~FixedSizeFreeList()
Destructor.
Definition FixedSizeFreeList.inl:8
void DestructObject(uint32 inObjectIndex)
Lockless destruct an object and return it to the free pool.
Definition FixedSizeFreeList.inl:178
void DestructObject(Object *inObject)
Lockless destruct an object and return it to the free pool.
Definition FixedSizeFreeList.inl:216
static const uint32 cInvalidObjectIndex
Definition FixedSizeFreeList.h:77
Object & Get(uint32 inObjectIndex)
Access an object by index.
Definition FixedSizeFreeList.h:115
const Object & Get(uint32 inObjectIndex) const
Access an object by index.
Definition FixedSizeFreeList.h:118
void AddObjectToBatch(Batch &ioBatch, uint32 inObjectIndex)
Definition FixedSizeFreeList.inl:111
A batch of objects that can be destructed.
Definition FixedSizeFreeList.h:100
uint32 mFirstObjectIndex
Definition FixedSizeFreeList.h:101
uint32 mNumObjects
Definition FixedSizeFreeList.h:103
uint32 mLastObjectIndex
Definition FixedSizeFreeList.h:102