Navigation
API > API/Runtime > API/Runtime/ChaosCore > API/Runtime/ChaosCore/Chaos
References
| Module | ChaosCore |
| Header | /Engine/Source/Runtime/Experimental/ChaosCore/Public/Chaos/ObjectPool.h |
| Include | #include "Chaos/ObjectPool.h" |
Syntax
template<typename ObjectType>
class TObjectPool
Constructors
| Type | Name | Description | |
|---|---|---|---|
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. | ||
TObjectPool
(
const TObjectPool& |
|||
TObjectPool
(
TObjectPool&& |
|||
TObjectPool
(
int32 InNumPerBlock, |
Destructors
| Type | Name | Description | |
|---|---|---|---|
~TObjectPool () |
Functions
| Type | Name | Description | |
|---|---|---|---|
| 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. | |
| void | 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. | ||
| int32 | Get the allocated (total) size of all blocks in the pool | ||
| int32 | GetCapacity () |
Gets the total number of items the pool can currently stor | |
| int32 | Get the number of allocated items. | ||
| int32 | Get the number of blocks currently allocated in the pool | ||
| int32 | GetNumFree () |
Gets the number of free items the pool has remaining | |
| int32 | Get the max number of items per block | ||
| float | GetRatio () |
Calculates the storage/overhead ratio of the pool. | |
| 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. | |
| 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. | |
| void | Reset () |
Reset the whole pool This will invalidate every currently live object from the pool. | |
| 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 |
Operators
| Type | Name | Description | |
|---|---|---|---|
| TObjectPool & | operator=
(
const TObjectPool& |
||
| TObjectPool & | operator=
(
TObjectPool&& |
Typedefs
Constants
| Name | Description |
|---|---|
| ItemAlign | Alignment of the stored type. |
| PaddedItemSize | Size of the item, plus padding up to the correct alignment so we can allocate the whole block with the correct size. |