Navigation
API > API/Plugins > API/Plugins/HarmonixDsp
A generic pool used to dynamically allocate objects Objects are stored as SharedPtrs Objects are returned as SharedPtrs So resetting the pool won't auto-delete items created by the pool
Implemented to be thread safe
| Name | TDynamicObjectPool |
| Type | class |
| Header File | /Engine/Plugins/Runtime/Harmonix/Source/HarmonixDsp/Public/HarmonixDsp/ObjectPool.h |
| Include Path | #include "HarmonixDsp/ObjectPool.h" |
Syntax
template<typename TObject>
class TDynamicObjectPool
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FSharedObjectPtr | TSharedPtr< TObject, ESPMode::ThreadSafe > | HarmonixDsp/ObjectPool.h | |
| FWeakObjectPtr | TWeakPtr< TObject, ESPMode::ThreadSafe > | HarmonixDsp/ObjectPool.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bAllowGrowth | bool | HarmonixDsp/ObjectPool.h | ||
| FactoryMethod | TFunction< FSharedObjectPtr()> | HarmonixDsp/ObjectPool.h | ||
| NumInUse | int32 | HarmonixDsp/ObjectPool.h | ||
| Objects | TArray< FSharedObjectPtr > | HarmonixDsp/ObjectPool.h | ||
| PoolLock | FCriticalSection | HarmonixDsp/ObjectPool.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Allocate
(
int32 Num, |
Allocates Num number of objects, given a factory method | HarmonixDsp/ObjectPool.h | |
bool CanGrow() |
HarmonixDsp/ObjectPool.h | ||
void ForEachObject
(
TUniqueFunction< void(FSharedObjectPtr)> DoWork |
HarmonixDsp/ObjectPool.h | ||
FSharedObjectPtr GetFreeShared() |
Get a "free" object from the pool, that isn't in use return value is TSharedPtr, so it'll stay valid even after the pool resets return null if there is no free instance. | HarmonixDsp/ObjectPool.h | |
FWeakObjectPtr GetFreeWeak() |
Get a "free" object from the pool, that isn't in use return value is TWeakPtr, so it's not guaranteed to be valid after the pool resets return null if there is no free instance. | HarmonixDsp/ObjectPool.h | |
int32 GetNumAllocated() |
HarmonixDsp/ObjectPool.h | ||
int32 GetNumFree() |
HarmonixDsp/ObjectPool.h | ||
int32 GetNumInUse() |
HarmonixDsp/ObjectPool.h | ||
bool IsInitialized() |
HarmonixDsp/ObjectPool.h | ||
void Reset() |
Resets the internal storage to no longer track allocated objects This does not immediately delete the allocated objects Deletion is managed by the SharedPtrs | HarmonixDsp/ObjectPool.h | |
void ReturnToPool
(
TSharedPtr< TObject > Object |
HarmonixDsp/ObjectPool.h | ||
int32 TryAllocate
(
int32 Num, |
Attempts to allocate Num number of objects, given a factory method Allows the FactoryMethod to return a nullptr, which will get culled from the pool. | HarmonixDsp/ObjectPool.h |