Constructor

@:value({ max : 999999999, initialCapacity : 64 })new(initialCapacity:Int = 64, max:Int = 999999999)

Parameters:

max

The maximum number of free objects to store in this pool.

Variables

@:value(0)max:Int = 0

The maximum number of objects that will be pooled.

@:value(0)peak:Int = 0

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

Methods

free(object:T):Void

reset(object: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}.

freeAll(objects:Array<T>):Void

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

See also:

  • free(Object)

clear():Void

Removes all free objects from this pool.

getFree():Int

The number of objects available to be obtained.

newObject():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.

obtain():T

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