Navigation
API > API/Runtime > API/Runtime/ChaosCore
| Name | TObjectPool |
| Type | class |
| Header File | /Engine/Source/Runtime/Experimental/ChaosCore/Public/Chaos/ObjectPool.h |
| Include Path | #include "Chaos/ObjectPool.h" |
Syntax
template<typename ObjectType>
class TObjectPool
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TObjectPool
(
TObjectPool&& |
Chaos/ObjectPool.h | ||
TObjectPool () |
No copy, no move, no default #TODO possibly add move and copy if the internal type is copy constructible but likely better to discourage copying. | Chaos/ObjectPool.h | |
TObjectPool
(
const TObjectPool& |
Chaos/ObjectPool.h | ||
TObjectPool
(
int32 InNumPerBlock, |
Chaos/ObjectPool.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~TObjectPool() |
Chaos/ObjectPool.h |
Structs
| Name | Remarks |
|---|---|
| FBlock | A block is an area of memory large enough to hold NumInBlock items, correctly aligned and provide items on demand to the pool |
| TItem | Storage for an item, and an index of the next free item if it's currently on the free list. |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FItem | TItem< ObjectType > | Helper alias for the item in this pool. | Chaos/ObjectPool.h |
| FObject | ObjectType | Chaos/ObjectPool.h | |
| FPtr | ObjectType * | Chaos/ObjectPool.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ItemAlign | int32 | Alignment of the stored type. | Chaos/ObjectPool.h |
| PaddedItemSize | int32 | Size of the item, plus padding up to the correct alignment so we can allocate the whole block with the correct size. | Chaos/ObjectPool.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Blocks | TArray< FBlock > | Chaos/ObjectPool.h | ||
| Capacity | int32 | Chaos/ObjectPool.h | ||
| FreeCount | int32 | Chaos/ObjectPool.h | ||
| NumPerBlock | int32 | Chaos/ObjectPool.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FPtr Alloc
(
TArgs&&... Args |
Allocate an object from the pool Returns an instance of the object type specified for this pool, either from the next available on the final block, the free list or by allocating a new block to continue providing objects. | Chaos/ObjectPool.h | |
void Free
(
FPtr Object |
Free a single object provided by this pool Takes an object previously allocated in this pool and frees it, accessing the pointer beyond a call to free is an undefined operation and could return garbage or an entirely different object. | Chaos/ObjectPool.h | |
int32 GetAllocatedSize() |
Get the allocated (total) size of all blocks in the pool | Chaos/ObjectPool.h | |
int32 GetCapacity() |
Gets the total number of items the pool can currently stor | Chaos/ObjectPool.h | |
int32 GetNumAllocated() |
Get the number of allocated items. | Chaos/ObjectPool.h | |
int32 GetNumAllocatedBlocks() |
Get the number of blocks currently allocated in the pool | Chaos/ObjectPool.h | |
int32 GetNumFree() |
Gets the number of free items the pool has remaining | Chaos/ObjectPool.h | |
int32 GetNumPerBlock() |
Get the max number of items per block | Chaos/ObjectPool.h | |
float GetRatio () |
Calculates the storage/overhead ratio of the pool. | Chaos/ObjectPool.h | |
void ReserveBlocks
(
int32 NumBlocks |
Makes sure the pool has at least NumBlocks blocks allocated Note: This will never reduce the number of blocks, it will only make sure the pool has at least NumBlocks block allocated, empty or not. | Chaos/ObjectPool.h | |
void ReserveItems
(
int32 NumItems |
Makes sure the pool has at least enough blocks allocated to store NumItems Not: This isn't a number of free items, but total items. | Chaos/ObjectPool.h | |
void Reset () |
Reset the whole pool This will invalidate every currently live object from the pool. | Chaos/ObjectPool.h | |
void ShrinkTo
(
int32 NumDesiredEmptyBlocks |
Shrinks the number of blocks All blocks that are not empty are kept, plus a number of empty blocks specified by the caller Passing zero will remove all empty blocks, leaving any non-empty blocks behind | Chaos/ObjectPool.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static void ConditionalDestruct
(
ObjectType* At |
Destruct helper This specialization is called for objects that actually require a destructor to be called (non trivial destruction). | Chaos/ObjectPool.h | |
static void ConditionalDestruct
(
ObjectType* |
Destruct helper This specialization is called for trivially destructible types (with no destructor). | Chaos/ObjectPool.h | |
static ObjectType * Construct
(
ObjectType* At, |
Construct helper this specialization is called for objects that are not trivially destructible as they require tracking of their construction state. | Chaos/ObjectPool.h | |
static ObjectType * Construct
(
ObjectType* At, |
Construct helper this specialization is called for objects that are trivially destructible as they require no tracking of their construction state | Chaos/ObjectPool.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TObjectPool & operator=
(
TObjectPool&& |
Chaos/ObjectPool.h | ||
TObjectPool & operator=
(
const TObjectPool& |
Chaos/ObjectPool.h |