PixelCrushers.Pool< T > Class Template Reference

This generic class implements an object pool. More...

Public Member Functions

Get ()
 Gets an object from the pool.
 
void Release (T item)
 Releases an object back to the pool.
 
void Allocate (int initialSize)
 Preallocates a number of objects into the pool.
 
void Trim (int max)
 Trims the pool to a maximum number of objects.
 

Detailed Description

This generic class implements an object pool.

It helps prevent garbage collection stutter by reusing objects without allocating and deallocating memory.

Type Constraints
T :new() 

Member Function Documentation

◆ Allocate()

void PixelCrushers.Pool< T >.Allocate ( int  initialSize)
inline

Preallocates a number of objects into the pool.

Parameters
initialSizeInitial size.

◆ Get()

T PixelCrushers.Pool< T >.Get ( )
inline

Gets an object from the pool.

After getting an object, you should initialize its fields because it will have the values from its previous use.

◆ Release()

void PixelCrushers.Pool< T >.Release ( item)
inline

Releases an object back to the pool.

Parameters
itemItem.

◆ Trim()

void PixelCrushers.Pool< T >.Trim ( int  max)
inline

Trims the pool to a maximum number of objects.

Parameters
maxMax objects.

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