Pool

Instance Members

spine
max: Int

The maximum number of objects that will be pooled.


spine
peak: Int

The highest number of free objects. Can be reset any time.


spine
free(object: spine.support.utils.Pool.T): Void
Name Type
object spine.support.utils.Pool.T

spine
reset(object: spine.support.utils.Pool.T): Void

Called when an object is freed to clear the state of the object for possible later reuse. The default implementation calls {@link Poolable#reset()} if the object is {@link Poolable}.

Name Type
object spine.support.utils.Pool.T

spine
freeAll(objects: Array<spine.support.utils.Pool.T>): Void

Puts the specified objects in the pool. Null objects within the array are silently ignored.

See: #free(Object)
Name Type
objects Array<spine.support.utils.Pool.T>

spine
clear(): Void

Removes all free objects from this pool.


spine
getFree(): Int

The number of objects available to be obtained.

Returns
Int

spine
newObject(): spine.support.utils.Pool.T

Puts the specified object in the pool, making it eligible to be returned by {@link #obtain()}. If the pool already contains {@link #max} free objects, the specified object is reset but not added to the pool.

Returns
spine.support.utils.Pool.T

spine
obtain(): spine.support.utils.Pool.T

Returns an object from this pool. The object may be new (from {@link #newObject()}) or reused (previously {@link #free(Object) freed}).

Returns
spine.support.utils.Pool.T

spine
new(?initialCapacity: Int = 64, ?max: Int = 999999999): Void
Name Type Default Description
initialCapacity Int 64
max Int 999999999 The maximum number of free objects to store in this pool.

Private Members

spine
freeObjects: Array<spine.support.utils.Pool.T>