A lightweight object pool
Constructor
new (factory:Void ‑> T, ?dispose:T ‑> Void, maxNumObjects:Int = -1)
Parameters:
factory | a function responsible for creating new objects. |
---|---|
dispose | a function responsible for disposing objects (optional).
|
maxNumObjects | the maximum allowed number of pooled object.
|
Variables
Methods
free ():Void
Destroys this object by explicitly nullifying all objects for GC'ing used resources. Improves GC efficiency/performance (optional).
inlineget ():T
Gets an object from the pool; the method either creates a new object if the pool is empty (no object has been returned yet) or returns an existing object from the pool. To minimize object allocation, return objects back to the pool as soon as their life cycle ends.