The type of objects managed by the pool. ObjectPool
Creates an instance of ObjectPool.
A factory function that returns a new instance of the object type T.
This function is called when the pool needs to create new objects.
OptionalinitialLength: number = 8The initial number of objects to create in the pool. If 0 is provided, the pool will default to a minimum growth size (currently 8) on the first acquire.
Acquires an object handle from the pool.
An ObjectHandle wrapping the acquired object.
InternalReleases an object handle back to the pool using its ID. This method is typically called internally by ObjectHandle#free. It pushes the object's ID back onto the stack of available IDs.
The ID of the object handle to release. Intended for use by ObjectHandle#free. Direct use is discouraged.
Releases all acquired objects back to the pool. This iterates through all objects managed by the pool, marks their handles as released, and resets the internal stack and pointer so that all objects are available for re-acquisition in their original order (0, 1, 2, ...). Note: This does NOT reset the state of the objects themselves.
Description
Manages a pool of reusable objects of type
T. This helps reduce the overhead of creating and garbage collecting objects by recycling instances.