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]; }
50 uint32 mNumObjectsAllocated;
53 ObjectStorage ** mPages =
nullptr;
61#ifdef JPH_ENABLE_ASSERTS
62 atomic<uint32> mNumFreeObjects;
66 atomic<uint32> mAllocationTag;
69 atomic<uint64> mFirstFreeObjectAndTag;
72 atomic<uint32> mFirstFreeObjectInNewPage;
88 template <
typename... Parameters>
114 inline Object &
Get(
uint32 inObjectIndex) {
return GetStorage(inObjectIndex).mObject; }
117 inline const Object &
Get(
uint32 inObjectIndex)
const {
return GetStorage(inObjectIndex).mObject; }
#define JPH_CACHE_LINE_SIZE
Definition: Core.h:492
unsigned int uint
Definition: Core.h:452
#define JPH_NAMESPACE_END
Definition: Core.h:378
std::uint32_t uint32
Definition: Core.h:455
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
@ 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:128
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:79
~FixedSizeFreeList()
Destructor.
Definition: FixedSizeFreeList.inl:8
void DestructObject(uint32 inObjectIndex)
Lockless destruct an object and return it to the free pool.
Definition: FixedSizeFreeList.inl:176
static const uint32 cInvalidObjectIndex
Invalid index.
Definition: FixedSizeFreeList.h:76
Object & Get(uint32 inObjectIndex)
Access an object by index.
Definition: FixedSizeFreeList.h:114
const Object & Get(uint32 inObjectIndex) const
Access an object by index.
Definition: FixedSizeFreeList.h:117
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:99
uint32 mFirstObjectIndex
Definition: FixedSizeFreeList.h:100
uint32 mNumObjects
Definition: FixedSizeFreeList.h:102
uint32 mLastObjectIndex
Definition: FixedSizeFreeList.h:101