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]; }
38#ifdef JPH_ENABLE_ASSERTS
39 atomic<uint32> mNumFreeObjects;
43 atomic<uint32> mAllocationTag;
46 atomic<uint64> mFirstFreeObjectAndTag;
61 uint32 mNumObjectsAllocated;
64 atomic<uint32> mFirstFreeObjectInNewPage;
67 ObjectStorage ** mPages =
nullptr;
86 template <
typename... Parameters>
112 inline Object &
Get(
uint32 inObjectIndex) {
return GetStorage(inObjectIndex).mObject; }
115 inline const Object &
Get(
uint32 inObjectIndex)
const {
return GetStorage(inObjectIndex).mObject; }
unsigned int uint
Definition: Core.h:439
#define JPH_NAMESPACE_END
Definition: Core.h:367
std::uint32_t uint32
Definition: Core.h:442
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
@ Object
Start of a new object.
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:124
uint32 ConstructObject(Parameters &&... inParameters)
Lockless construct a new object, inParameters are passed on to the constructor.
Definition: FixedSizeFreeList.inl:54
static const int ObjectStorageSize
Size of an object + bookkeeping for the freelist.
Definition: FixedSizeFreeList.h:77
~FixedSizeFreeList()
Destructor.
Definition: FixedSizeFreeList.inl:8
void DestructObject(uint32 inObjectIndex)
Lockless destruct an object and return it to the free pool.
Definition: FixedSizeFreeList.inl:172
static const uint32 cInvalidObjectIndex
Invalid index.
Definition: FixedSizeFreeList.h:74
Object & Get(uint32 inObjectIndex)
Access an object by index.
Definition: FixedSizeFreeList.h:112
const Object & Get(uint32 inObjectIndex) const
Access an object by index.
Definition: FixedSizeFreeList.h:115
void AddObjectToBatch(Batch &ioBatch, uint32 inObjectIndex)
Definition: FixedSizeFreeList.inl:109
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11
A batch of objects that can be destructed.
Definition: FixedSizeFreeList.h:97
uint32 mFirstObjectIndex
Definition: FixedSizeFreeList.h:98
uint32 mNumObjects
Definition: FixedSizeFreeList.h:100
uint32 mLastObjectIndex
Definition: FixedSizeFreeList.h:99