Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RHI::ObjectPool< Traits > Class Template Reference

#include <ObjectPool.h>

Classes

struct  Descriptor
 

Public Types

using ObjectType = typename Traits::ObjectType
 The type of object created and managed by this pool. Must inherit from Object.
 
using ObjectFactoryType = typename Traits::ObjectFactoryType
 The type of the object factory. An instance of this object.
 
using ObjectFactoryDescriptor = typename ObjectFactoryType::Descriptor
 The type of the descriptor used to initialize the object factory.
 
using ObjectCollectorType = ObjectCollector< Traits >
 The type of object collector used by the object pool.
 
using MutexType = typename Traits::MutexType
 

Public Member Functions

 ObjectPool (ObjectPool &rhs)=delete
 
void Init (const Descriptor &descriptor)
 Initializes the pool to an empty state.
 
void Shutdown ()
 Shutdown the pool. The user must re-initialize to use it again.
 
template<typename... Args>
ObjectTypeAllocate (Args &&... args)
 
void DeAllocate (ObjectType *object)
 
void DeAllocate (ObjectType *objects, size_t objectCount)
 
void DeAllocate (ObjectType **objects, size_t objectCount)
 
void Collect ()
 Performs an object collection cycle. Objects which are collected can be reused by Allocate.
 
void CollectForce ()
 Performs an object collection cycle that ignores the collect latency, processing all objects.
 
size_t GetObjectCount () const
 Returns the total number of objects in the pool.
 
const ObjectFactoryTypeGetFactory () const
 

Detailed Description

template<typename Traits>
class AZ::RHI::ObjectPool< Traits >

This class is a simple deferred-release pool allocator for objects. It's useful when objects are being tracked on the GPU timeline, such that they require an N frame latency before being reused. For example: command lists which are being submitted to the GPU each frame. The derived type must inherit from Object.

Member Function Documentation

◆ Allocate()

template<typename Traits >
template<typename... Args>
ObjectType * AZ::RHI::ObjectPool< Traits >::Allocate ( Args &&...  args)
inline

Allocates an instance of an object from the pool. If no free object exists, it will create a new instance from the factory. If a free object exists, it will reuse that one.

◆ DeAllocate()

template<typename Traits >
void AZ::RHI::ObjectPool< Traits >::DeAllocate ( ObjectType object)
inline

Frees an object back to the pool. Depending on the object collection latency, it may take several cycles before the object is reused again.


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