Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
FixedSizeFreeList< Object > Class Template Reference

#include <FixedSizeFreeList.h>

Inheritance diagram for FixedSizeFreeList< Object >:
NonCopyable

Classes

struct  Batch
 A batch of objects that can be destructed. More...
 

Public Member Functions

 ~FixedSizeFreeList ()
 Destructor. More...
 
void Init (uint inMaxObjects, uint inPageSize)
 Initialize the free list, up to inMaxObjects can be allocated. More...
 
template<typename... Parameters>
uint32 ConstructObject (Parameters &&... inParameters)
 Lockless construct a new object, inParameters are passed on to the constructor. More...
 
void DestructObject (uint32 inObjectIndex)
 Lockless destruct an object and return it to the free pool. More...
 
void DestructObject (Object *inObject)
 Lockless destruct an object and return it to the free pool. More...
 
void AddObjectToBatch (Batch &ioBatch, uint32 inObjectIndex)
 
void DestructObjectBatch (Batch &ioBatch)
 Lockless destruct batch of objects. More...
 
ObjectGet (uint32 inObjectIndex)
 Access an object by index. More...
 
const ObjectGet (uint32 inObjectIndex) const
 Access an object by index. More...
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Static Public Attributes

static const uint32 cInvalidObjectIndex = 0xffffffff
 Invalid index. More...
 
static const int ObjectStorageSize = sizeof(ObjectStorage)
 Size of an object + bookkeeping for the freelist. More...
 

Detailed Description

template<typename Object>
class FixedSizeFreeList< Object >

Class that allows lock free creation / destruction of objects (unless a new page of objects needs to be allocated) It contains a fixed pool of objects and also allows batching up a lot of objects to be destroyed and doing the actual free in a single atomic operation

Constructor & Destructor Documentation

◆ ~FixedSizeFreeList()

Destructor.

Member Function Documentation

◆ AddObjectToBatch()

template<typename Object >
void FixedSizeFreeList< Object >::AddObjectToBatch ( Batch ioBatch,
uint32  inObjectIndex 
)
inline

Add a object to an existing batch to be destructed. Adding objects to a batch does not destroy or modify the objects, this will merely link them so that the entire batch can be returned to the free list in a single atomic operation

◆ ConstructObject()

template<typename Object >
template<typename... Parameters>
uint32 FixedSizeFreeList< Object >::ConstructObject ( Parameters &&...  inParameters)
inline

Lockless construct a new object, inParameters are passed on to the constructor.

◆ DestructObject() [1/2]

template<typename Object >
void FixedSizeFreeList< Object >::DestructObject ( Object inObject)
inline

Lockless destruct an object and return it to the free pool.

◆ DestructObject() [2/2]

template<typename Object >
void FixedSizeFreeList< Object >::DestructObject ( uint32  inObjectIndex)
inline

Lockless destruct an object and return it to the free pool.

◆ DestructObjectBatch()

template<typename Object >
void FixedSizeFreeList< Object >::DestructObjectBatch ( Batch ioBatch)
inline

Lockless destruct batch of objects.

◆ Get() [1/2]

template<typename Object >
Object & FixedSizeFreeList< Object >::Get ( uint32  inObjectIndex)
inline

Access an object by index.

◆ Get() [2/2]

template<typename Object >
const Object & FixedSizeFreeList< Object >::Get ( uint32  inObjectIndex) const
inline

Access an object by index.

◆ Init()

template<typename Object >
void FixedSizeFreeList< Object >::Init ( uint  inMaxObjects,
uint  inPageSize 
)
inline

Initialize the free list, up to inMaxObjects can be allocated.

Member Data Documentation

◆ cInvalidObjectIndex

template<typename Object >
const uint32 FixedSizeFreeList< Object >::cInvalidObjectIndex = 0xffffffff
static

Invalid index.

◆ ObjectStorageSize

template<typename Object >
const int FixedSizeFreeList< Object >::ObjectStorageSize = sizeof(ObjectStorage)
static

Size of an object + bookkeeping for the freelist.


The documentation for this class was generated from the following files: