Type of the objects stored in the pool
A function that's called when hydrating the pool, which must return new instances of objects to populate it. It must return a different instance each time.
An optional function called when an object is released.
Configuration
The number of objects left in the pool
The number of used objects in the pool
The total number of objects created by this pool
Retrieves a single object. If the pool has no available objects it first hydrates the pool.
The object retrieved from the pool
Enlarges the list of available objects by the specified number.
Number of objects to create
Releases an object back into the pool
The object to be released. It should be an object previously retrieved from the pool.)
Generated using TypeDoc
An object pool allows to reuse the same instance of an object multiple times without the relatively costly operation of instantiating it. It's especially useful when you need to create and destroy objects quickly (eg. bullets/particles) or create a lot of them at once (eg. loading a level).
This class will prevent the following incorrect usages: